无为清净楼资源网 Design By www.qnjia.com
在jsp页面上导入.xls文件,报错:
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)
不知道是什么原因?应该怎样来解决呢?
解决这个错误,需要在form表单里面加上加enctype=”multipart/form-data” 这个属性,不过表单请求传到另一个jsp或servlet里时,是不能用request.getParameter()来获取到各个表单元素的值的,如下:
复制代码 代码如下:
<%@ 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 = "";
//获取配置参数,文件类型,文件大小
/*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('错误:文件类型错误!');");
out.println("</script>");
return;
}
//判断文件夹是否存在,不存在创建
String file_path = SysPara.getValue("dxt_sms_multi_sender_file_path");
file_path=file_path.replace("\\","//");
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('错误:文件大小超出限制!');");
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>
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)
不知道是什么原因?应该怎样来解决呢?
解决这个错误,需要在form表单里面加上加enctype=”multipart/form-data” 这个属性,不过表单请求传到另一个jsp或servlet里时,是不能用request.getParameter()来获取到各个表单元素的值的,如下:
复制代码 代码如下:
<%@ 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 = "";
//获取配置参数,文件类型,文件大小
/*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('错误:文件类型错误!');");
out.println("</script>");
return;
}
//判断文件夹是否存在,不存在创建
String file_path = SysPara.getValue("dxt_sms_multi_sender_file_path");
file_path=file_path.replace("\\","//");
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('错误:文件大小超出限制!');");
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页面,导入,xls文件
无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com
暂无评论...
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。
更新日志
2024年11月16日
2024年11月16日
- 于文文.2024-天蝎座【华纳】【FLAC分轨】
- 黄雨勳《魔法列车首部曲》[FLAC/分轨][173.61MB]
- 群星《歌手2024 第13期》[320K/MP3][50.09MB]
- 群星《歌手2024 第13期》[FLAC/分轨][325.93MB]
- 阿木乃《爱情买卖》DTS-ES【NRG镜像】
- 江蕾《爱是这样甜》DTS-WAV
- VA-Hair(OriginalBroadwayCastRecording)(1968)(PBTHAL24-96FLAC)
- 博主分享《美末2RE》PS5 Pro运行画面 玩家仍不买账
- 《双城之战2》超多新歌MV发布:林肯公园再次献声
- 群星《说唱梦工厂 第11期》[320K/MP3][63.25MB]
- 群星《说唱梦工厂 第11期》[FLAC/分轨][343.07MB]
- 群星《闪光的夏天 第5期》[320K/MP3][79.35MB]
- 秀兰玛雅.1999-友情人【大旗】【WAV+CUE】
- 小米.2020-我想在城市里当一个乡下人【滚石】【FLAC分轨】
- 齐豫.2003-THE.UNHEARD.OF.CHYI.3CD【苏活音乐】【WAV+CUE】