JAVA+JSP显示中文乱码
public String execute(){
ActionContext act=ActionContext.getContext();
HttpServletRequest request=(HttpServletRequest) act.get(ServletActionContext.HTTP_REQUEST);
HttpServletResponse response=(HttpServletResponse) act.get(ServletActionContext.HTTP_RESPONSE);
PrintWriter out=response.getWriter();
request.setCharacterEncoding( "UTF-8 ");
response.setCharacterEncoding( "UTF-8 ");
System.out.println( "这里中文没事 ");
out.println( "不能输入中文 ");
}
在控制台:这里中文没事
浏览器中:???????
求高人指点 不胜感激
------解决方案--------------------
顺序错了。 试试看调整这样的。
request.setCharacterEncoding( "UTF-8 ");
response.setCharacterEncoding( "UTF-8 ");
PrintWriter out=response.getWriter();
//这句在那两句下面