使用过滤器解决乱码问题
此情况只使用与Servlet+jsp,对struts不适合
public class CharacterFilter implements Filter {public void destroy() {// TODO Auto-generated method stub}public void doFilter(ServletRequest request, ServletResponse response,FilterChain chain) throws IOException, ServletException {// TODO Auto-generated method stubrequest.setCharacterEncoding("utf-8");response.setCharacterEncoding("utf-8");response.setContentType("text/html;charset=UTF-8");MyRequest myrequest = new MyRequest((HttpServletRequest) request);chain.doFilter(myrequest, response);}public void init(FilterConfig arg0) throws ServletException {// TODO Auto-generated method stub}}class MyRequest extends HttpServletRequestWrapper {HttpServletRequest request;public MyRequest(HttpServletRequest request) {super(request);this.request = request;}@Overridepublic String getParameter(String name) {String value = super.getParameter(name);if (request.getMethod().equalsIgnoreCase("get")) {try {value = new String(value.getBytes("iso8859-1"), "utf-8");} catch (UnsupportedEncodingException e) {// TODO Auto-generated catch blocke.printStackTrace();}}return value;}}