1
public class FeedUpdaterServlet extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
PrintWriter out = resp.getWriter();
req.setCharacterEncoding("utf-8");
resp.setLocale(Locale.TAIWAN);
resp.setContentType("text/html; charset=utf-8");
resp.setCharacterEncoding("utf-8");
resp.getWriter().println("Hello, [email protected]!");
out.println("我是人"); //some chinese character
out.println(resp.getCharacterEncoding());
out.flush();
out.close();
}
}
웹 XML응답 인코딩 (응답 인코딩을 변경할 수 없습니다)
<locale-encoding-mapping-list>
<locale-encoding-mapping>
<locale>zh_TW</locale>
<encoding>utf-8</encoding>
</locale-encoding-mapping>
</locale-encoding-mapping-list>
출력 : 안녕하세요, 세계! @! ??? ISO-8859-1
응답의 인코딩을 변경할 수없는 것 같습니다. 무슨 일이 있습니까?
를? – InsaurraldeAP