在struts2 中的 struts.xml中添加如下信息
(项目中使用的struts2的版本是2.3.24)
<bean type= "org.apache.struts2.dispatcher.multipart.MultiPartRequest"
name= "myRequestParser" class= "com.wondersgroup.ws.intercept.ParseWrapper"
scope= "default" optional= "true" />
<constant name= "struts.multipart.parser" value= "myRequestParser" /> ParseWrapper 类
package com.wondersgroup.ws.intercept;
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequest;
public class ParseWrapper extends JakartaMultiPartRequest{
@Override
public void parse(HttpServletRequest arg0, String arg1) throws IOException {
//什么都不用写
}
}
本文详细介绍了在使用Struts2框架时如何配置多部分请求解析器,并通过自定义封装类实现特定功能。重点讲解了ParseWrapper类的实现与作用。

808

被折叠的 条评论
为什么被折叠?



