已发布内容类型不是多部分/表单数据IO异常

时间:2015-07-29 05:02:43

标签: java jsp post weblogic

我想问一些问题,最近我不得不将我们的遗留应用程序迁移到weblogic,但是某些功能无法使用(多部分发布表单),这是我的代码:

noticeWrite.jsp:

<%@ page language="java" contentType="text/html; charset=UTF-8"

    pageEncoding="UTF-8"%>

<% request.setCharacterEncoding("UTF-8"); %>

<%@ page import="common.Util"%>

<%@ page import="common.Const"%>

<%

String lang_cls=Util.nullChk(request.getParameter("lang_cls"),"eng");

String sectn_nm=Util.nullChk(request.getParameter("sectn_nm"),"notice");

System.out.println("request.getContentType() ====> " + request.getContentType());

%>

<jsp:include flush="true" page="/admin/include/top_brd.jsp" />

<jsp:include flush="true" page="/admin/include/board_left.jsp" />



<form name="frm" method="post" action="noticeProc.jsp" onsubmit="return frmSubmit(this)">

    <input type="hidden" name="mode" value="insert">

    <input type="hidden" name="lang_cls" value="<%=lang_cls%>">

    <input type="hidden" name="sectn_nm" value="<%=sectn_nm%>">

    <input type="hidden" name="board_seq" value="">

<!--right start-->

<div id="subRight">

<h3><%=Const.getConstant(sectn_nm)%>

<p class="homeNevi"><img src="../.././common/home_imgs/neviHome.gif"

    alt="Home" />  <span></span>  Administrator  <span>></span> 

Data & Informasi  <span>></span>  <%=Const.getConstant(sectn_nm)%>

</p>

</h3>





<!--edit start-->

<div class="bleStyle_border">

<table cellspacing="0" cellpadding="3" frame="void" border="1px"

    bordercolor="#b1a587" class="homeList">

    <caption> </caption>

    <colgroup>

        <col style="width: 80px;" />

        <col style="" />

        <col style="width: 80px;" />

        <col style="width: 260px;" />

    </colgroup>

    <tr>

        <th scope="row">* Judul</th>

        <td colspan="3"><input type="text" name="board_titl"

            msg="Please type a title" maxlength="100" class="iput_txt"

            style="width: 99%;" /></td>

    </tr>

    <tr>

        <th scope="row">* Penulis</th>

        <td><input type="text" name="make_nm" msg="Please type a writer"

            maxlength="20" value="${sess_mbr_id}" class="iput_txt"

            style="width: 97%;" /></td>

        <th scope="row">File</th>

        <td class="bleLeft"><input type="file" name="file_1"

            class="iput_file" onkeypress="blur()" /></td>

    </tr>

    <tr>

        <td colspan="4"><textarea cols="" rows="" name="board_cntt"

            msg="Please type a content" maxlength="5000" class="bleText_area"

            style="width: 98%; height: 100px;"></textarea>

            <script language="JavaScript1.2">

                editor_generate('board_cntt');

            </script>   

        </td>

    </tr>

</table>

</div>



<div class="bleBtn_box"><!--future extention of buttons is considered. so, buttons without class is orderly backward. be cautious!-->

<a href="javascript:goToPage('noticeList.jsp','')"><img

    src="../.././common/home_imgs/daftar_btn.gif" alt="" /></a><!--daftar_btn button-->

<input type="image" src="../.././common/home_imgs/kirim_btn.gif" alt=""

    class="btnLeft" /><!--kirim_btn button--></div>

</div>

<!--right start-->

</form>

<script type="text/javascript">

<!--

function frmSubmit(form){

    form.encoding = "multipart/form-data";

    return chkNull(form);

}

//-->

</script>

<jsp:include flush="true" page="/admin/include/board_bottom.jsp" />

noticeProc.jsp

<%@ page import="board.NoticeBoardMng"%>

<%@ page import="entity.Board"%>

<%@ page language="java" contentType="text/html; charset=UTF-8"    pageEncoding="UTF-8"%>

<%@ page import="common.Util,

                com.oreilly.servlet.MultipartRequest,

                com.oreilly.servlet.multipart.DefaultFileRenamePolicy"%>

<%

request.setCharacterEncoding("UTF-8");



String savePath= Util.getMessage("filepath","NOTICE_FILE_PATH");

//System.out.println("savePath =====> " + savePath);

int sizeLimit=5*1024*1024;

//MultipartRequest multi=new MultipartRequest(request,savePath,sizeLimit,"UTF-8",new DefaultFileRenamePolicy());

MultipartRequest multi = new MultipartRequest(request,savePath,sizeLimit,"UTF-8");



String mode       = Util.nullChk(multi.getParameter("mode"));

String board_seq  = Util.nullChk(multi.getParameter("board_seq"));

String lang_cls   = Util.nullChk(multi.getParameter("lang_cls"));

String sectn_nm   = Util.nullChk(multi.getParameter("sectn_nm"));

String make_nm    = Util.nullChk(multi.getParameter("make_nm"));

String board_titl = Util.nullChk(multi.getParameter("board_titl"));

String board_cntt = multi.getParameter("board_cntt");

String file_1     = Util.nullChk(multi.getFilesystemName("file_1"));

String sfield     = Util.nullChk(multi.getParameter("sfield"));

String sword      = Util.nullChk(multi.getParameter("sword"));

String nowPage    = Util.nullChk(multi.getParameter("nowPage"));



//board_cntt=Util.transHtml(board_cntt);



Board board=new Board();

board.setBoard_seq(board_seq);

board.setLang_cls(lang_cls);

board.setSectn_nm(sectn_nm);

board.setMake_nm(make_nm);

board.setBoard_titl(board_titl);

board.setBoard_cntt(board_cntt);

board.setBoard_cntt_long(board_cntt);



if(file_1 == null){

    board.setFile_1("");

}else{

    board.setFile_1(file_1);

}

%>

<html>

<head>

<script language="javascript" src="/common/js/common.js"></script>

</head>

<body>

<form name="frm" method="post" action="">

<input type="hidden" name="lang_cls" value="<%=lang_cls%>">

<input type="hidden" name="sectn_nm" value="<%=sectn_nm%>">

<input type="hidden" name="board_seq" value="">

<input type="hidden" name="sfield" value="<%=sfield%>">

<input type="hidden" name="sword" value="<%=sword%>">

<input type="hidden" name="nowpage" value="<%=nowPage%>">

</form>

<%

boolean isSuccess=false;

NoticeBoardMng bMng=new NoticeBoardMng();



if("insert".equals(mode)){

    isSuccess=bMng.saveBoard(board);

    if(isSuccess){

        out.println("<script language='javascript'>");

        out.println("goToPage('noticeList.jsp','"+board_seq+"')");

        out.println("</script>");

    }else{

        out.println("<script language='javascript'>");

        out.println("alert('fail!');");

        out.println("history.back();");

        out.println("</script>");

    }   

}else if("update".equals(mode)){

    isSuccess=bMng.updateBoard(board);

    if(isSuccess){

        out.println("<script language='javascript'>");

        out.println("goToPage('noticeList.jsp','')");

        out.println("</script>");

    }

}

%>

</body>

</html>

问题是,当我点击提交按钮时,文件存储到服务器但文本字段和文本区域值没有存储到数据库并引发错误:

java.io.IOException: Posted content type isn&#39;t multipart/form-data

    at com.oreilly.servlet.multipart.MultipartParser.<init>(MultipartParser.java:130)

    at com.oreilly.servlet.multipart.MultipartParser.<init>(MultipartParser.java:94)

    at com.oreilly.servlet.MultipartRequest.<init>(MultipartRequest.java:219)

    at com.oreilly.servlet.MultipartRequest.<init>(MultipartRequest.java:170)

    at jsp_servlet._admin._board.__noticeproc._jspService(__noticeproc.java:109)

    at weblogic.servlet.jsp.JspBase.service(JspBase.java:35)

    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)

    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)

    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:301)

    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:185)

    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3732)

    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3696)

    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)

    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)

    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2273)

    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179)

    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1490)

    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)

    at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)

我需要你的建议,这有什么问题?因为它在tomcat上工作正常,但不能在weblogic下运行,谢谢。

编辑:

从错误日志中,它在__noticeproc.java:109上显示错误,这里是内容:

  

String savePath = Util.getMessage(“filepath”,“NOTICE_FILE_PATH”);   //System.out.println("savePath =====&gt;“+ savePath); INT   的sizeLimit = 5 * 1024 * 1024; // MultipartRequest multi = new   MultipartRequest(请求,savePath,的sizeLimit, “UTF-8”,新   DefaultFileRenamePolicy()); MultipartRequest multi = new   MultipartRequest(请求,savePath,的sizeLimit, “UTF-8”)

这是来自firebug的参数:

  

内容类型:multipart / form-data;   边界= --------------------------- 2572913021633   内容长度:1092

     

----------------------------- 2572913021633   内容处理:表格数据;名称= “模式”

     

插入   ----------------------------- 2572913021633   内容处理:表格数据;名称= “lang_cls”

     

主机   ----------------------------- 2572913021633   内容处理:表格数据;名称= “sectn_nm”

     

office3   ----------------------------- 2572913021633   内容处理:表格数据;名称= “board_seq”

     

----------------------------- 2572913021633   内容处理:表格数据;名称= “board_titl”

     

TestPage   ----------------------------- 2572913021633   内容处理:表格数据;名称= “make_nm”

     

地理信息技术   ----------------------------- 2572913021633   内容处理:表格数据; NAME = “file_1”; filename =“”内容类型:   应用/八位字节流

     

----------------------------- 2572913021633   内容处理:表格数据;名称= “board_cntt”

     

testpage   ----------------------------- 2572913021633   内容处理:表格数据;名称= “X”

     

57   ----------------------------- 2572913021633   内容处理:表格数据; NAME = “Y”

     

5   ----------------------------- 2572913021633 -

1 个答案:

答案 0 :(得分:0)

您需要在表单标记中添加此属性:enctype="multipart/form-data"并从您手动设置的提交功能中删除。