当前位置: 技术问答>java相关
如何在Tomcat里面显示中文?我编译成Servlet后中文变成了乱码!
来源: 互联网 发布时间:2015-01-11
本文导语: | 在你的Servlet文件中加入特定编码"charset=gb2312"吧 如: public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=gb2312"); PrintWriter ou...
|
在你的Servlet文件中加入特定编码"charset=gb2312"吧
如:
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html;charset=gb2312");
PrintWriter out = response.getWriter();
String ss="我是中文字符!";
out.println(ss);
}
如:
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html;charset=gb2312");
PrintWriter out = response.getWriter();
String ss="我是中文字符!";
out.println(ss);
}