Home > Back-end >  JSP on the web page display garbled words will submit your work in a great god for help
JSP on the web page display garbled words will submit your work in a great god for help

Time:09-22

The myeclipse window without garbled words but with a browser open garbled words


CodePudding user response:

Match filter,,
 import javax.mail. Servlet. *; 
The import javax.mail. Servlet. The annotation. WebFilter;
import java.io.IOException;

@ WebFilter (filterName="encodingFilter", urlPatterns={} "*")
Public class encodingFilter implements Filter {
Public void destroy () {
}

Public void doFilter (ServletRequest the req, ServletResponse resp, FilterChain chain) throws ServletException, IOException {
The req. SetCharacterEncoding (" utf-8 ");
Resp. SetCharacterEncoding (" utf-8 ");
Chain. DoFilter (the req, resp);
}

Public void init (FilterConfig config) throws ServletException {

}

}

CodePudding user response:

In the server without this two sentences can add try:
The response. SetContentType (" text/HTML; Charest=utf-8 ");
The response. SetCharacterEncoding (" utf-8 ");

If not try the above request also

CodePudding user response:

In the server without this two sentences can add try:
The response. SetContentType (" text/HTML; Charest=utf-8 ");
The response. SetCharacterEncoding (" utf-8 ");
  • Related