问题
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