servlet 显示不了汉字

freecare 2004-10-12 07:17:55
为什么显示出来的是"????"呢
该如何改这段程序?谢谢
public class MyTestServlet extends HttpServlet {

/**Initialize global variables*/
public void init(ServletConfig config) throws ServletException {
super.init(config);
}
/**Process the HTTP Get request*/
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = response.getWriter();
out.println("<%@ page contentType=\"text/html;charset=GBK\"%>");
out.println("<html>");
out.println("<head><title>MyTestServlet</title></head>");
out.println("<body>");

out.println("<p>小应用程序</p>");

out.println("</body>");
out.println("</html>");
}
/**Clean up resources*/
public void destroy() {
}
}
...全文
65 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
freecare 2004-10-13
  • 打赏
  • 举报
回复
非常感谢,这个问题困扰了我两天了!
tutor666 2004-10-12
  • 打赏
  • 举报
回复
response.setContentType("text/html;charset=GBK");

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧