java.lang.IllegalArgumentException: No bean specified

來源:互聯網
上載者:User

用的是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方法... 

解決!!

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.