论坛首页 入门技术论坛

j2ee的中文问题

浏览 922 次
该帖已经被评为新手帖
作者 正文
   发表时间:2008-02-26  
<%@ 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();会出现乱码?
论坛首页 入门技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics