Character Encoding - RequestDispatcher

大兔子大兔子 提交于 2019-12-24 02:37:05

问题


I have a servlet and I use

String error = "error";
request.setAttribute("loginError", error);
request.setCharacterEncoding("UTF-8");
request.getRequestDispatcher("/index.jsp").forward(request, response);

and I use

<%@ page language="java" contentType="text/html; charset=ISO-8859-9"
pageEncoding="ISO-8859-9"%>

in my jsp page, also

request.setCharacterEncoding("UTF-8");

But if I forward a page, this pages' encoding does not work. How can I handle this encoding? Thanks.


回答1:


I had the same problem and i found your unanswered question. I solved it with adding

response.setContentType("text/html;charset=UTF-8");


来源:https://stackoverflow.com/questions/16112030/character-encoding-requestdispatcher

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!