当前位置: 编程技术>java/j2ee
如何解决在jsp页面上导入.xls文件报错问题
来源: 互联网 发布时间:2014-10-18
本文导语: 在jsp页面上导入.xls文件,报错: java.io.IOException: Posted content type isn't multipart/form-data at com.oreilly.servlet.multipart.MultipartParser.(MultipartParser.java:166) at com.oreilly.servlet.MultipartRequest.(MultipartRequest.java:222) at org.apache.jsp.dxt.sms.multi_005fsender...
在jsp页面上导入.xls文件,报错:
java.io.IOException: Posted content type isn't multipart/form-data
at com.oreilly.servlet.multipart.MultipartParser.(MultipartParser.java:166)
at com.oreilly.servlet.MultipartRequest.(MultipartRequest.java:222)
at org.apache.jsp.dxt.sms.multi_005fsender.upload_jsp._jspService(upload_jsp.java:406)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:386)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
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 sdcncsi.ict.security.AclFilter.doFilter(AclFilter.java:78)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at sdcncsi.ict.web.RequestFilter.doFilter(RequestFilter.java:108)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
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:127)
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:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:619)
不知道是什么原因?应该怎样来解决呢?
解决这个错误,需要在form表单里面加上加enctype=”multipart/form-data” 这个属性,不过表单请求传到另一个jsp或servlet里时,是不能用request.getParameter()来获取到各个表单元素的值的,如下:
function myunload(){
window.opener.callback_getPageData_table_list(1);
}
var res='';
if(res=='true')
{
sys_ajaxPost("/dxt/multi_sender.do?method=importmulti_sender&accountid=&excelpath=","",function(msg){
if(msg.result==true){
location.href="/tech-java/${ctx}/dxt/sms/multi_sender/multi_sender/result/true.html";
}else{
location.href="/tech-java/${ctx}/dxt/sms/multi_sender/multi_sender/result/false.html";
}
});
}
java.io.IOException: Posted content type isn't multipart/form-data
at com.oreilly.servlet.multipart.MultipartParser.(MultipartParser.java:166)
at com.oreilly.servlet.MultipartRequest.(MultipartRequest.java:222)
at org.apache.jsp.dxt.sms.multi_005fsender.upload_jsp._jspService(upload_jsp.java:406)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:386)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
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 sdcncsi.ict.security.AclFilter.doFilter(AclFilter.java:78)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at sdcncsi.ict.web.RequestFilter.doFilter(RequestFilter.java:108)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
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:127)
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:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:619)
不知道是什么原因?应该怎样来解决呢?
解决这个错误,需要在form表单里面加上加enctype=”multipart/form-data” 这个属性,不过表单请求传到另一个jsp或servlet里时,是不能用request.getParameter()来获取到各个表单元素的值的,如下:
代码如下:
function myunload(){
window.opener.callback_getPageData_table_list(1);
}
var res='';
if(res=='true')
{
sys_ajaxPost("/dxt/multi_sender.do?method=importmulti_sender&accountid=&excelpath=","",function(msg){
if(msg.result==true){
location.href="/tech-java/${ctx}/dxt/sms/multi_sender/multi_sender/result/true.html";
}else{
location.href="/tech-java/${ctx}/dxt/sms/multi_sender/multi_sender/result/false.html";
}
});
}