struts 1.2 整合 spring时getServlet() 为空
<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
</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
...全文
相关推荐
Struts1中配置数据源
2. **在web.xml中配置上下文参数**:接下来,需要在`WEB-INF/web.xml`文件中配置Struts1的`ActionServlet`,使其知道数据源的位置。
STRUTS问题详解
总的来说,Struts2相对于Struts1,在架构设计、数据处理和扩展性方面都进行了显著改进,更加适应现代Web开发的需求。
Struts实现文件上传
在Struts1.2版本中,实现文件上传是一项常见的需求,例如用户在网站上提交表单时可能需要上传图片、文档等文件。
处理ssh组合框架中如何用getBean获取实体
**不同方法获取bean** - **方法1:BaseDispatchAction** `BaseDispatchAction`通常是Struts中的一个基类,它可能已经包含了对Spring上下文的引用
国央企在推动科技创新时,如何利用技术交易系统实现全流程闭环管理?.docx
国央企在推动科技创新时,如何利用技术交易系统实现全流程闭环管理?


