struts 1.2 整合 spring时getServlet() 为空
什么都不能 2008-02-27 01:30:52 <action path="/upload" type="org.springframework.web.struts.DelegatingActionProxy" scope="request" >
</action>
<bean name="/upload" class="com.test.struts.action.UploadAction" singleton="false"></bean>
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception{
UploadForm f = (UploadForm) form;
FormFile file=f.getAttachment();
byte[] data=file.getFileData();
49: String filePath=getServlet().getServletContext().getRealPath("/upload");
System.out.println(filePath);
FileOutputStream fo=new FileOutputStream(filePath+"/"+file.getFileName());
fo.write(data);
int size=file.getFileSize();
String type=file.getContentType();
Map mp=new HashMap();
mp.put("size", size);
mp.put("type",type);
request.setAttribute("property", mp);
return new ActionForward("/result.jsp");
}
49行报NullPointerException