jquery easyui from 表单返回乱码!

山城忙碌人 2012-09-27 05:19:53
如题,代码如下:
1:JS:代码
     $("#form1").form({
url : "testServlet",
method:"post",
onSubmit : function(none) {
return $(this).form('validate');
},
success : function(data) {
$.messager.alert("提示", data);
}
});

2:服务端代码
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
String message = "{success:true,message:";
String name = request.getParameter("name");
System.out.println(name);
String eml = request.getParameter("eml");
String word = request.getParameter("word");
String age = request.getParameter("age");
String url = request.getParameter("url");
message = message +"name "+name+"<br/>eml "+eml+"<br/>word "+word+"<br/>age "+age+"<br/>url "+url + "}";
response.getWriter().println(message );
}

现像是:在火弧下不是乱码!火弧浏览器编码是utf-8,在IE6下全是乱码,IE编码也是utf-8!请问下是什么原因!
...全文
1498 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
dddsfdfgfdgfdg 2014-12-08
  • 打赏
  • 举报
回复
引用 12 楼 mrkai218 的回复:
如果用easyui的form进行提交,必须在<form>标签中加入属性method="post",即<form method="post"></form>。否则,就得在后台controller里面自己转换代码了,比较麻烦。
使用该成功解决了
z2007130205 2013-12-11
  • 打赏
  • 举报
回复
spring mvc下用 @ResponseBody直接写到前台如何解决乱码,response.setContentType("text/html;charset=utf-8")不好使。method="post"也不好使
z2007130205 2013-12-11
  • 打赏
  • 举报
回复
引用 10 楼 mrchailiu 的回复:
后台加上一句response.setContentType("text/html;charset=utf-8");
spring mvc下用 @ResponseBody直接写到前台如何解决乱码,response.setContentType("text/html;charset=utf-8")不好使。
kunsyliu 2013-11-06
  • 打赏
  • 举报
回复
引用 12 楼 mrkai218 的回复:
如果用easyui的form进行提交,必须在<form>标签中加入属性method="post",即<form method="post"></form>。否则,就得在后台controller里面自己转换代码了,比较麻烦。
楼上的正解
mrkai218 2013-07-10
  • 打赏
  • 举报
回复
如果用easyui的form进行提交,必须在<form>标签中加入属性method="post",即<form method="post"></form>。否则,就得在后台controller里面自己转换代码了,比较麻烦。
山城忙碌人 2012-10-09
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 的回复:]
后台加上一句response.setContentType("text/html;charset=utf-8");
[/Quote]


谢谢,引用了你的方法后解决了!
MRchai__ 2012-10-07
  • 打赏
  • 举报
回复
后台加上一句response.setContentType("text/html;charset=utf-8");
兼哲 2012-10-05
  • 打赏
  • 举报
回复
那就别用嘛

[Quote=引用 6 楼 的回复:]

引用 4 楼 的回复:

差不多,如果不包含文件使用的是jquery.ajax提交,如果包含,则提交到隐藏的iframe中,然后给iframe添加onload事件获取加载完毕后输出的到iframe中的json格式的字符串内容



我都不想使用这个jquery easyui 这个组件了!
[/Quote]
zgb09023228 2012-10-05
  • 打赏
  • 举报
回复
提交表单、所有中文value
用String name = request.getParameter("name");
name = new String(name.getBytes("iso8859-1"),"utf-8");
system.out.println(name);应该就不会出现乱码了!!!
山城忙碌人 2012-09-29
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 的回复:]

,IE6.。。。

jquery使用了encodeURIComponent编码,对于统一为utf-8编码应该不会出乱码吧。。。换台有IE6的电脑试试看
[/Quote]

兄弟是jquery easyui 的form提交的,不过和jquery一样!应该不是电脑的原因吧!
Go 旅城通票 2012-09-29
  • 打赏
  • 举报
回复


提交到iframe最保险。。不过照理说只要文件编码和网站编码统一为utf-8,基本很少出错乱码的问题。。
山城忙碌人 2012-09-29
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 的回复:]

差不多,如果不包含文件使用的是jquery.ajax提交,如果包含,则提交到隐藏的iframe中,然后给iframe添加onload事件获取加载完毕后输出的到iframe中的json格式的字符串内容
[/Quote]


我都不想使用这个jquery easyui 这个组件了!
山城忙碌人 2012-09-29
  • 打赏
  • 举报
回复
不小得怎么会乱码,我很无语!
Go 旅城通票 2012-09-29
  • 打赏
  • 举报
回复
差不多,如果不包含文件使用的是jquery.ajax提交,如果包含,则提交到隐藏的iframe中,然后给iframe添加onload事件获取加载完毕后输出的到iframe中的json格式的字符串内容
Go 旅城通票 2012-09-27
  • 打赏
  • 举报
回复
,IE6.。。。

jquery使用了encodeURIComponent编码,对于统一为utf-8编码应该不会出乱码吧。。。换台有IE6的电脑试试看
山城忙碌人 2012-09-27
  • 打赏
  • 举报
回复
IE6乱码是FROM提交后返回的汉字是乱码!

52,797

社区成员

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

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