日期:2014-05-19  浏览次数:20839 次

j2ee的中文问题
<%@ page language="java" import="java.util.*" pageEncoding="GB18030" contentType="text/html; charset=gbk"%>
<html>
  <body>
   <center>
      <form action="test.do">
         <input type="submit" value="提交">
      </form>
   </center>
  </body>
</html>

public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)throws IOException {
System.out.println(request.getCharacterEncoding());
System.out.println(response.getCharacterEncoding());
      PrintWriter out=response.getWriter();
          out.println("<script type='text/javascript'>alert('欢迎您!');history.back();</script>");
return null;
}
为什么打印出来是:
null
ISO-8859-1


System.out.println(request.getCharacterEncoding());打印是空的为什么?
System.out.println(response.getCharacterEncoding());打印出来的不是gbk吗?

设了contentType="text/html; charset=gbk",为什么在页面上alert();会出现乱码?