Struts Chinese garbled problem solved

xiaoxiao2021-03-06  106

The main method is to join a filter Web.xml to join the following: set character encoding setcharacterencodingfilter set character encoding / *

SetcharacterenceeCodingFilter.java

Package edu.bit.dick.Article;

import java.io.IOException; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import Javax.Servlet.unavailableException;

Public class setcharacterencodingfilter imports filter {public void init (filter void in) throws servletexception {} public void destroy () {}

public void doFilter (ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {request.setCharacterEncoding ( "GB18030"); // passes control to the next filter chain.doFilter (request, response);}}

转载请注明原文地址:https://www.9cbs.com/read-104068.html

New Post(0)