jsp request乱码
来源:互联网 发布:数据分析师月薪 编辑:程序博客网 时间:2024/06/06 11:39
<%@ pagelanguage="java"contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE htmlPUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<metahttp-equiv="Content-Type"content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%--
下面是解决乱码:
1.修改tomcat配置文件server.xml
URIEncoding='UTF-8'
<Connector connectionTimeout="20000" port="8080"
protocol="HTTP/1.1" redirectPort="8443" URIEncoding="UTF-8">
2.通过代码实现转换
1)get请求
jsp中用encodeURI
后台用java.net.URLDecoder或者
getBytes("ISO-8859-1",'UTF-8');
=》接收页面:
<%
String name=request.getParameter("name");
//get转码1:推荐
name=new String(name.getBytes("iso-8859-1"),"utf-8");
//get转码2
name=URLDecoder.decode(name,"utf-8");
但是要提交之前在js里执行:
<script>
function login(){
var loginForm=document.forms["loginForm"];
loginForm.name.value=encodeURI(loginForm.name.value)
loginForm.submit();
}
</script>
out.println(name);
%>
2)处理post请求
request.setCharacterEncoding("UTF-8")
--%>
<formaction="g.jsp"name="loginForm">
<inputtype="text"name="name">
<inputtype="submit">
</form>
</body>
</html>
- jsp-request中文乱码
- JSP request页面乱码
- jsp request乱码
- jsp request 乱码问题
- JSP response request 中文乱码
- jsp request.getParameter()乱码问题 乱码
- 解决JSP中使用request乱码问题
- 解决JSP中使用request乱码问题
- 解决JSP中使用request乱码问题
- JSP关于request.getParameter("");中文乱码问题
- JSP中request.getParameter()乱码问题
- 解决JSP中使用request乱码问题
- 解决JSP中使用request乱码问题
- [转]JSP中request.getParameter()乱码问题
- jsp中request传递参数汉字乱码
- JSP中request.getParameter()乱码问题
- jsp中request传递参数汉字乱码
- JSP Request.getParameter中文乱码的误区
- 命名管道
- 1065. A+B and C (64bit) (20)
- CSU-1005
- 微信支付集成
- node.js第五天
- jsp request乱码
- 10种使测试人员陷入困境的行为趋势
- 反射相关
- JZOJ 3506. 【NOIP2013模拟11.4A组】善良的精灵
- SQ的工具应用代码
- 二叉搜索树的相关操作:插入节点,删除节点,排序,查找,最大值,最小值,前序,中序,后序遍历(主要用到递归的方法)
- 计算机二级复习趣谈
- SpringMVC与Struts2的区别
- Android SQLite 数据库增删改查dos命令行语句