回 帖 发 新 帖 刷新版面

主题:JSP中文问题求助--高手请进

大家好,
我这里有个文件send.jsp,代码如下:
<%@ page import="java.sql.*" contentType="text/html;charset=GB2312" %>
<html>
  <body>
   <%
     request.setCharacterEncoding("GB2312");
     String name = request.getParameter("name");
   %>
   <%= name %>
  </body>
</html>

我在浏览器地址栏中输入:
http://localhost:8080/send.jsp?name=大海
为什么不能显示“大海”,而只显示????
哪位高手帮忙解决一下好吗?
谢谢

回复列表 (共2个回复)

沙发

<%@ page import="java.sql.*" contentType="text/html;charset=GB2312" %>
<html>
  <body>
   <%
     request.setCharacterEncoding("GB2312");
     String name = request.getParameter("name");
     Byte[] b=name.getByte("ISO-8859-1");
     String s=new String(b);
     name=s;
   %>
   <%= name %>
  </body>
</html>
就ok了!

板凳

谢谢2楼
但是这样改了的话,
我下面这样传参数就变??了
<jsp:forward page="send.jsp">
<jsp:param name="name" value="大海"/>
</jsp:forward>

我来回复

您尚未登录,请登录后再回复。点此登录或注册