表单提交出现乱码!

licunzhi 2006-03-22 09:28:59
<%@ page language="java" %>
<%@ page contentType="text/html;charset=GB2312" %>
<%@ page import="java.util.*" %>
<!DOCTYPE HTML PUBLIC "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>

<title>选择物品的页面</title>
</head>
<body bgcolor="#FFFFFF">
<jsp:useBean id="buy" class="gwpack.Buy" scope="session">
</jsp:useBean>
<center>
<P>选择您要购买的商品添加到购物车:
<%String str=response.encodeRedirectUrl("add.jsp"); %>
<form action="<%=str%>" method=post name=form>
<select name="item" value=" 没选择">
<option value="TV"> 电视机
<option value="apple"> 苹果
<option value="rom"> JSP教程
<option value="phone"> 手机
<option value="tea"> 茶叶
</option>

</select>
<P>输入购买的数量:
<Input type=t"text" name="mount">
<P>选择计量单位:
<INPUT type="radio" name="unit" value="个">个
<INPUT type="radio" name="unit" value="公斤">公斤
<INPUT type="radio" name="unit" value="台">台
<INPUT type="radio" name="unit" value="瓶">瓶 <br>
<input type="submit" value="提交"></input>
</form>
<P>您的购物车有如下商品:
<% Hashtable list=buy.show();
Enumeration enum=list.elements();
while(enum.hasMoreElements()){
String goods=(String)enum.nextElement();
byte b[]=goods.getBytes("ISO-8859-1");
// goods=new String(goods.getBytes("ISO-8859-1"),UTF-8);
out.print("<BR>"+goods);
}
%>
<%String str1=response.encodeRedirectUrl("select.jsp"); %>
<FORM action="<%=str1%>" method=post name=form>
<Input type=submit value="修改购物车中的货物">
</FORM>

</center>
</body>
</html>



<P>您的购物车有如下商品:
<% Hashtable list=buy.show();
Enumeration enum=list.elements();
while(enum.hasMoreElements()){
String goods=(String)enum.nextElement();
byte b[]=goods.getBytes("ISO-8859-1");
// goods=new String(goods.getBytes("ISO-8859-1"),UTF-8);
out.print("<BR>"+goods);
}
%>
执行这里出现乱码!
怎么解决?
...全文
96 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
aywrenyue 2006-03-22
  • 打赏
  • 举报
回复
应当注意,取码和解码的过程
evilzydar 2006-03-22
  • 打赏
  • 举报
回复
查看网页当前编码是什么~

网页中加一句<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
试试
rickhunterchen 2006-03-22
  • 打赏
  • 举报
回复
看看这里:
http://www.blogjava.net/rickhunter/articles/33571.html

81,122

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧