`

java.lang.IllegalArgumentException: No bean specified

    博客分类:
  • bug
阅读更多
用的是struts1,ActionForm类如下:
private String menuType;
private ClientUser user;
...相应的get和set方法...

Action类如下:
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
                System.out.println(" =========进入UserInfoAction类=========");
		UserInfoForm userInfoForm = (UserInfoForm) form;

}

但是在进行表单提交的时候碰到下面的问题:
   
 =========进入UserInfoAction类=========
2012-4-20 17:24:46 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet action threw exception
java.lang.IllegalArgumentException: No bean specified
	at org.apache.commons.beanutils.PropertyUtilsBean.getPropertyDescriptor(PropertyUtilsBean.java:751)
	at org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:937)
	at org.apache.commons.beanutils.BeanUtilsBean.populate(BeanUtilsBean.java:811)
	at org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:298)
	at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:493)
	at org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:816)
	at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:203)
	at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
	at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.udrm.bms.struts.beans.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:54)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
	at java.lang.Thread.run(Unknown Source)

如果我不进行表单提交,那么是没有错误的,只要进行表单提交了就有错误。很显然,这个是进入了Action类的execute方法的,通过debug调试发现,当UserInfoForm userInfoForm = (UserInfoForm)form获取表单值得时候就报错了。从网上查找了一些资料,说在ActionForm中只要是自定义的对象的属性,那么都需要进行初始化new 一下这个对象。也就是我的ActionForm需要改为:
private String menuType;
[color=red][b]private ClientUser user=new ClientUser();//必须new一下 [/b][/color]
...相应的get和set方法...

这样就没有问题了。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics