有关上传文件的问题(java.lang.
IllegalArgumentException)
我想上传文件
jsp页面的表单中:
<form id= "form1 " name= "form1 " onsubmit= "return check() "
method= "post " enctype= "multipart/form-data " action= " <%=request.getContextPath() %> /song.do ">
地址: <input name= "saddress " type= "file " id= "saddress " />
如果没有 enctype= "multipart/form-data " 那么程序可以正常运行
但是 这句是上传格式必须用到的啊,我加上这句,再运行
就报异常 java.lang.IllegalArgumentException 说参数
SongForm.java内容:
private String saddress;
public String getSaddress() {
return saddress;
}
public void setSaddress(String saddress) {
this.saddress = saddress;
}
------解决方案--------------------jf
------解决方案--------------------哥们啥原因,给大家都说说!
------解决方案--------------------如果lz使用的是struts的话,需要写一个类继承
org.apache.struts.action.RequestProcessor
主要是override,doForward这个方法就可以了。
原因参考:http://www.ojava.net/simple/index.php?t2900.html
package xxx;
import
java.io.IOException;
import
javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.upload.MultipartRequestWrapper;
public class RequestProcessor extends org.apache.struts.action.RequestProcessor {
protected void doForward(String uri, HttpServletRequest request,
HttpServletResponse response) throws
IOException,
ServletException {
HttpServletRequest myRequest = request;
if (request instanceof MultipartRequestWrapper) {
myRequest = ((MultipartRequestWrapper) request).getRequest();
}
super.doForward(uri, myRequest, response);
}
}
------解决方案--------------------学习。。。接分。。。