Go homepage(回首页) Upload pictures (上传图片) Write articles (发文字帖)
The author:(作者)归海一刀published in(发表于) 2014/3/16 2:52:13 Ajax开发过程中提交获取数据的乱码问题_[AJAX教程]
通过在后台用UTF8转码的方式可以解决中文乱码问题。这种方法针对form表单提交,编码在服务器完成。代码如下:
form.jsp: <%@ page contentType="text/html; charset=gb2312"%>表单提交测试 用户名: 密码:
form_handle.jsp:<%@ page contentType="text/html; charset=gb2312" language="java" errorPage="" %><%String username = new String(request.getParameter("username").getBytes("ISO-8859-1"),"UTF8");String password = request.getParameter("password");System.out.println("用户名:"+username);System.out.println("密码:"+password);out.println(username+"|"+password);%> 来源:http://blog.csdn.net/javatwt
赞