Method 1 : The most basic method
stay response.getWriter().write(); Previous input of
response.setContentType("text/html;charset=GBK");
response.setContentType("text/html");
It's solved .

Method 2 : Add a filter , Don't worry about coding anymore .

Remember to note in the front @webFilter(" What you want to filter servlet"), This annotation can only be used in version3.1 have access to , Other versions below should be configured by yourself xml file
package Filter; 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.annotation.WebFilter;
@WebFilter("/*") public class AFilter implements Filter { // Filter all character encoding sets @Override
public void destroy() { // TODO Auto-generated method stub } @Override public
void doFilter(ServletRequest request, ServletResponse response, FilterChain
chain) throws IOException, ServletException {
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=UTF-8"); chain.doFilter(request,
response); } @Override public void init(FilterConfig arg0) throws
ServletException { // TODO Auto-generated method stub } }

Technology
©2019-2020 Toolsou All rights reserved,
Solve in servlet The Chinese output in is a question mark C String function and character function in language MySQL management 35 A small coup optimization Java performance —— Concise article Seven sorting algorithms (java code ) use Ansible Batch deployment SSH Password free login to remote host according to excel generate create Build table SQL sentence Spring Source code series ( sixteen )Spring merge BeanDefinition Principle of Virtual machine installation Linux course What are the common exception classes ?