Struts处理接收参数乱码问题(actionForm接受的参数发送至数据库成乱码)的解决办法:
- package com.aptech.jb.epet.web.action;
- public class EncodingActionServlet extends ActionServlet{
- public void process(HttpServletRequest request,
- HttpServletResponse response)
- throws ServletException ,IOException{
- request.setCharacterEncoding("GBK"); //处理乱码
- super.process(request, response); //调用父类方法
- }
- }
第二步,修改WEB-INF/web.xml配置为:
- <servlet>
- <servlet-name>action</servlet-name>
- <servlet-class>com.aptech.jb.epet.web.action.EncodingActionServlet</servlet-class>
- </servlet>
- //其他代码略,就是将原来的ActionServlet修改为自定义的ActionServlet的子类