argument type mismatch异常解决办法

我们在利用struts框架开发项项目时,会通过表单来提交数据。数据包括直接从文本框接收用户的输入,也有通过导入文件的方式,以及导入本地图片等。

    直接从文本框输入的话,可以提交至服务器。在提交文本文件数据时,会出现argument type mismatch异常。详细异常如下:

java.lang.IllegalArgumentException: argument type mismatch
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.apache.commons.beanutils.PropertyUtils.setSimpleProperty(PropertyUtils.java:1789)
 at org.apache.commons.beanutils.PropertyUtils.setNestedProperty(PropertyUtils.java:1684)
 at org.apache.commons.beanutils.PropertyUtils.setProperty(PropertyUtils.java:1713)
 at org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:1019)
 at org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808)
 at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1252)
 at org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:821)
 at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254)
 at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
 at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at Encoding.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:20)
 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:175)
 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:844)
 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)

 

解决这个异常的方法:在表单的属性中加入enctype属性设置其属性值为enctype="multipart/form-data"即可。

你可能感兴趣的:(match)