.CodeFormat {font-family:"Courier New", Courier, mono; font-size:10pt; }
一句话...Struts的Action Servlet存在缺陷...用继承吧...
package net.csdn.blog.xport.struts;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionServlet;
public class ActionServletUTF8Encoding extends ActionServlet {
protected void process(HttpServletRequest request,
HttpServletResponse response)
throws java.io.IOException, javax.servlet.ServletException {
//如果JSP用GBK,这里就用GBK吧!
request.setCharacterEncoding("UTF-8");
super.process(request, response);
}
}
然后,在web.xml中,做如下设定即可:
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>net.csdn.blog.xport.struts.ActionServletUTF8Encoding</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>application</param-name>
<param-value>ApplicationResources</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>