当前位置:首页 > servlet中文乱码显示为??的解决方法

servlet中文乱码显示为??的解决方法

点击次数:1238  更新日期:2018-07-02

方法一:设置response的header为utf-8编码

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    response.setHeader("content-type","text/html;charset=UTF-8");

    PrintWriter writer = response.getWriter();

    writer.write("3333344445553故人西辞黄鹤楼");

}

方法二:myeclipse中,window=》preferences=》general=》workspace 设置text file encoding 为other UTF-8

QQ截图20180702140652.jpg