Eclipse中println输出html中文乱码

**

Eclipse中println输出html中文乱码

错误代码:
Eclipse中println输出html中文乱码
输出:Eclipse中println输出html中文乱码
这是由于文本编码类型不对导致的。
解决办法:
添加这几句话:request.setCharacterEncoding(“GBK”);
response.setContentType(“text/html;charSet=GBK”);


```java
package demo;


import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebInitParam;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class FirstServlet extends HttpServlet {
	
    
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		request.setCharacterEncoding("GBK");
		response.setContentType("text/html;charSet=GBK");
		PrintWriter out =response.getWriter();
		out.println("<html><body><font color=red size=20 >集美大学123</font></body></html>");
		
		out.close();
	}
}

`问题解决!!!

Eclipse中println输出html中文乱码

上一篇:编码方式


下一篇:MySQL数据库入门——常用基础命令