日期:2014-05-17  浏览次数:20697 次

项目从tomcat5.5移植到weblogic10后,上传功能出错。
以下代码在tomcat环境下没有问题。但是在weblogic环境下后台实体类获得的值为null那位高手可以帮忙解答以下,谢谢
jsp代码: 
<form name="listForm" action="notice!save.action" method="POST"  enctype="multipart/form-data" >
<table border="1" width="100%" cellspacing="1" cellpadding="2" align="center" class="table_edit_border">
<!--<input type="hidden" name="notice.ncid" value="<ww:property value="notice.ncid"/>"/>--> 
<tr>
        <td class="table_edit_cell_border" width="21%" align="right" class="tdbg" height="25" ><font color="red">*</font>标&nbsp;&nbsp;&nbsp;&nbsp;题:</td>
        <tr>
        <td class="table_edit_cell_border" width="21%" align="right" class="tdbg" height="25" >附&nbsp;&nbsp;&nbsp;&nbsp;件:</td>
     <td class="table_edit_cell_border" width="79%"  title="附件" colspan="2" class="tdbg"><input type="file" name="upload" style="800px;" /></td>
</tr>
</table>
</form>
---------------------------------------------

action代码:
public String save() {
try {
if (upload != null) {
String path_ = ServletActionContext.getRequest().getSession()
.getServletContext().getRealPath("/");
try {
System.out.println(uploadFileName+"---====");
FileUtils.createPaths(path_ + "uploaddir\\");
FileUtils.copyFile(upload, path_ + "uploaddir\\"
+ uploadFileName);
} catch (FileUtilException e) {
e.printStackTrace();
}
// 上传文件
notice.setAttch(path_ + "uploaddir\\" + uploadFileName);
notice.setAttachmentname(uploadFileName);
}
inoticeService.save(notice);
inoticeService.savePd(notice.getS_date(), notice.getDescription());
return "save";
} catch (Exception e) {
e.printStackTrace();
this.addErrors(e.getMessage(), e);
return ERROR;
}



--------------------------------
debug发现if (upload != null)  这一步upload为null。
inoticeService.save(notice); 这一步notice也为null。
如果我在from中去掉enctype="multipart/form-data"属性后,后台notice就是有值的,前台加上enctype="multipart/form-data"属性后,以上两步就都是null了。 
weblogic上传功能 tomcat移植到weblogic enctype multipart/form-data

------解决方案--------------------
有enctype="multipart/form-data",request.getXXX就不能用了,改用别的组件吧。