为什么不用struts里的FormFile.
第一个问题,应该是你的smartupload没有调用initialize方法.
第二个问题,应该是你的smartupload.getRequest().getParameter方法是获得
form里面其他的元素。
第一个问题,应该是你的smartupload没有调用initialize方法.
第二个问题,应该是你的smartupload.getRequest().getParameter方法是获得
form里面其他的元素。
private ServletConfig config;
//Initialize global variables
final public void init(ServletConfig config) throws ServletException {
this.config = config;
}
04/11/10 09:20:14 java.lang.NullPointerException04/11/10 09:20:14 at com.jspsmart.upload.SmartUpload.initialize(SmartUpload.java:136)04/11/10 09:20:14 at tw.com.fiti.a2.action.HistoryQuery.execute(HistoryQuery.java:40)04/11/10 09:20:14 at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)04/11/10 09:20:14 at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)04/11/10 09:20:14 at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1485)04/11/10 09:20:14 at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:527)04/11/10 09:20:14 at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)04/11/10 09:20:14 at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)04/11/10 09:20:14 at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:778)04/11/10 09:20:14 at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:317)04/11/10 09:20:15 at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)04/11/10 09:20:15 at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:270)04/11/10 09:20:15 at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)04/11/10 09:20:15 at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)04/11/10 09:20:15 at java.lang.Thread.run(Thread.java:536)
private ServletConfig config;
//Initialize global variables
final public void init(ServletConfig config) throws ServletException {
this.config = config;
}
这是在severlet中的写法,而在struts中的Action中正确的写法是:
mySmartUpload.initialize(this.getServlet().getServletConfig(),request,response);这样问题就解决了.