日期:2014-05-20  浏览次数:20651 次

还是编码问题,请高手指教
运行以下代码时,出现乱码。请问什么问题??当前系统是utf-8

<%@ page contentType="text/html;charset=GBK" %>
<%
 request.setCharacterEncoding("GBK");
%>
<html>
<head>
<title>下拉菜单</title>
</head>
</html>

另外我还有一个问题就是当前系统是utf-8的编码为什么经过编写jsp以下代码后,还会出现乱码??系统编译无错误。 
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<html>
  <head>
   
  <title>下拉框</title>
   
  </head>
  <body bgcolor="#ffffff">
  <center>
  <h2>下拉菜单</h2>
  <hr>
  <form action="test.jsp" method="post">
  <p><select name="city" size="3">
  <option value="Guangzhou">广州市</option>
  <option>上海市</option>
  <option>天津市</option>
  <option>济南市</option>
  <option>青岛市</option> 
  < </select></p>
  <p><input type="submit" value="提 交"></p>
  <hr>
</form>
</center>

  </body>

</html>





<html>
  <head>
   
  <title>下拉菜单演示</title>
  </head>
  <body bgcolor=#ffffff>
  <center>
  <h2 algin=center>下拉菜单演示</h2>
  <hr>
   
  <p align=center>您选择的城市是"<%=request.getParameter("city")%>"。</p>
  </body>
</html>
<html>
  <head>
  <title>允许多重选择的下拉框</title>
  </head>
  <body bgcolor=#ffffff>
   
  <h3>允许复选的下拉框</h3>
  <hr>
   
   
</html>





------解决方案--------------------
<%@ page contentType="text/html;charset=UTF-8" %> 
<% 
request.setCharacterEncoding("UTF-8"); 
%> 

------解决方案--------------------
全部都用 utf-8 
你的第一个页面不是 GBK?
得到表单对象前先给request设置utf-8
------解决方案--------------------
String ename=(String)request.getParameter("dn");
String name=new String(name.getBytes("ISO8859-1"),"GBK");
转一下试试看
------解决方案--------------------
或者在显示表单数据的页面写上:
<% 
request.setCharacterEncoding("gbk"); 
%>