Jetty response character encoding

前端 未结 5 2091
旧时难觅i
旧时难觅i 2021-01-13 03:46

How do I set the default character encoding on my responses to UTF-8?

I\'ve tried this

    System.setProperty(\"file.encoding\", \"UTF-8\");
<         


        
5条回答
  •  迷失自我
    2021-01-13 04:35

    It matter when you use Writer();

    For me If I write

    resp.getWriter().println("Return");
    resp.setContentType("text/html; charset=UTF-8");
    

    I won't work

    But if I change the sequence

    resp.setContentType("text/html; charset=UTF-8");
    resp.getWriter().println("Return");
    

    It will be alright

提交回复
热议问题