一种解决方式就是重写一个继承自org.apache.struts.action.ActionServlet的GBKActionServlet,在其process方法中调用request.setCharacterEncoding("GB2312");
如下:
package com.webex.util
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionServlet;
public class GBKActionServlet extends ActionServlet
{
protected void process(HttpServletRequest request, HttpServletResponse response) throws IOException,
ServletException
{
request.setCharacterEncoding("GB2312");
super.process(request, response);
}
}
然后在web.xml中关于struts配置中的
<servlet-name>action</servlet-name>
<servlet-class>
org.apache.struts.action.ActionServlet
</servlet-class>
改为:
<servlet-name>action</servlet-name>
<servlet-class>
com.webex.util.GBKActionServlet
</servlet-class>