上传文件时候遇到的小异常
exception
javax.servlet.ServletException: BeanUtils.populate
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:495)
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:796)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:203)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1192)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:430)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
com.grxxh.filter.EncodingFilter.doFilter(EncodingFilter.java:23)
com.grxxh.filter.EncodingFilter.doFilter(EncodingFilter.java:23)
root cause
java.lang.IllegalArgumentException: Cannot invoke com.grxxh.struts.form.AddHpsshnForm.setTheFile - argument type mismatch
org.apache.commons.beanutils.PropertyUtilsBean.invokeMethod(PropertyUtilsBean.java:1778)
org.apache.commons.beanutils.PropertyUtilsBean.setSimpleProperty(PropertyUtilsBean.java:1759)
org.apache.commons.beanutils.PropertyUtilsBean.setNestedProperty(PropertyUtilsBean.java:1648)
org.apache.commons.beanutils.PropertyUtilsBean.setProperty(PropertyUtilsBean.java:1677)
org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:1022)
org.apache.commons.beanutils.BeanUtilsBean.populate(BeanUtilsBean.java:811)
org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:298)
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:493)
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:796)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:203)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1192)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:430)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
com.grxxh.filter.EncodingFilter.doFilter(EncodingFilter.java:23)
com.grxxh.filter.EncodingFilter.doFilter(EncodingFilter.java:23)
引用一个图片上传表单测试时报错如下:
Cannot invoke com.crbt123.web.form.MyfaceForm.setFile - argument type mismatch
原因:FORM缺少 enctype="multipart/form-data"
entype:表单HTTP方法的编码类型。
后来隐约想起来好像是王哥说过 上传文件的时候 表单要特殊处理。