一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

如何解決在jsp頁面上導(dǎo)入.xls文件報(bào)錯(cuò)問題

在jsp頁面上導(dǎo)入.xls文件,報(bào)錯(cuò):
Java.io.IOException: Posted content type isn't multipart/form-data
at com.oreilly.servlet.multipart.MultipartParser.<init>(MultipartParser.Java:166)
at com.oreilly.servlet.MultipartRequest.<init>(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)
不知道是什么原因?應(yīng)該怎樣來解決呢?
解決這個(gè)錯(cuò)誤,需要在form表單里面加上加enctype=”multipart/form-data” 這個(gè)屬性,不過表單請(qǐng)求傳到另一個(gè)jsp或servlet里時(shí),是不能用request.getParameter()來獲取到各個(gè)表單元素的值的,如下:
復(fù)制代碼 代碼如下:
<%@ page language="Java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page session="false"%>
<%@ include file="/common/taglibs.jsp"%>
<%@ include file="/common/meta.jsp"%>
<%@ include file="/common/js.jsp"%>
<%@ page import="Java.util.*"%>
<%@ page import="Java.text.SimpleDateFormat"%>
<%@ page import="sdcncsi.ict.util.SysPara"%>
<%@page import="Java.io.*,Java.util.*,sdcncsi.ict.base.attachment.*"%>
<%@ page import="sdcncsi.ict.util.RequestUtil"%>
<%@page import="com.oreilly.servlet.MultipartRequest"%>
<%
String res="true";
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html; charset=UTF-8");
String file=(String)request.getParameter("t_file_excel");
//System.out.println(file);
String accountid3=(String)request.getParameter("accountid3");
String saveDirectory = "";
//獲取配置參數(shù),文件類型,文件大小
/*String date = "";
SimpleDateFormat gs = new SimpleDateFormat("yyyyMMdd");
Date now = new Date();
date = gs.format(now);*/
FileFuns fileFuns = new FileFuns();
try {
//判斷文件類型
String file_type=SysPara.getValue("dxt_sms_multi_sender_file_type");
if(!file.substring(file.lastIndexOf(".")+1).equals(file_type))
{
out.println("<script>");
out.println("alert('錯(cuò)誤:文件類型錯(cuò)誤!');");
out.println("</script>");
return;
}
//判斷文件夾是否存在,不存在創(chuàng)建
String file_path = SysPara.getValue("dxt_sms_multi_sender_file_path");
file_path=file_path.replace("http://","http://");
if (!fileFuns.getFileIsExists(file_path)) {
fileFuns.Createdir(file_path);
}
String file_size = SysPara.getValue("dxt_sms_multi_sender_file_size");
//文件上傳后,保存在saveDirectory
saveDirectory = file_path;
RandomFileRenamePolicy rfrp = new RandomFileRenamePolicy();
MultipartRequest multi = null;
System.out.println("saveDirectory"+saveDirectory);
System.out.println("file_size"+file_size);
multi = new MultipartRequest(request, saveDirectory, Integer
.parseInt(file_size), "utf-8", rfrp);
System.out.println("222"+multi);
//輸出反饋信息
Enumeration files = multi.getFileNames();
while (files.hasMoreElements()) {
String name = (String) files.nextElement();
File f = multi.getFile(name);
if (f != null) {
String fileName = multi.getFilesystemName(name);
saveDirectory+=fileName;
}
}
} catch (Exception eu) {
res="false";
eu.printStackTrace();
out.println("<script>");
out.println("alert('錯(cuò)誤:文件大小超出限制!');");
out.println("</script>");
}
%>
<head>
<script type="text/Javascript">
function myunload(){
window.opener.callback_getPageData_table_list(1);
}
</script>
<base target="_self">
</head>
<body onunload="myunload()">
<a id="reload" href='' style="display:none"></a>
</body>
<script>
var res='<%=res%>';
if(res=='true')
{
sys_ajaxPost("/dxt/multi_sender.do?method=importmulti_sender&accountid=<%=accountid3%>&excelpath=<%=saveDirectory %>","",function(msg){
if(msg.result==true){
location.href="${ctx}/dxt/sms/multi_sender/multi_sender.jsp?result=true";
}else{
location.href="${ctx}/dxt/sms/multi_sender/multi_sender.jsp?result=false";
}
});
}
</script>

jsp技術(shù)如何解決在jsp頁面上導(dǎo)入.xls文件報(bào)錯(cuò)問題,轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 怡红院美国分院一区二区 | 国产精品视频观看 | 男女男精品视频网站 | 97精品久久天干天天蜜 | 亚洲视频入口 | 色爱区综合激月婷婷激情五月 | 青青精品 | 国产91精品高清一区二区三区 | 香蕉在线视频网站 | 日韩一区二区三区免费 | 国产精品久久自在自2021 | 日本免费视屏 | 成人激情视频网 | 四虎最新入口 | 漂亮大学生一级毛片 | 91一区二区午夜免费福利网站 | 91短视频免费在线观看 | 草草线在成人免费视频 | 亚洲综合激情小说 | 美女黄页视频 | 四虎国产精品免费观看 | 亚洲第一se情网站 | 欧美日韩国产码高清综合人成 | 成人信息集中地 | 婷婷色视频 | 六月色播 | 韩国免费一级片 | 国产色拍 | 在线视频天堂 | 四虎最新网站 | 最近免费中文在线视频 | 伊人久久久久久久久久 | 99pao成人国产永久免费视频 | 午夜毛片免费观看视频 | 在线视频亚洲一区 | 精品在线看 | 人人视频在线观看 | 韩国一级毛片在线观看 | 国产精品久久久久久久牛牛 | 国产91色 | 亚洲精品美女久久久aaa |