jsp 提交表单以什么编码格式提交,都设置utf-8了为什么提交到后来是乱码

J2EE 码拜 9年前 (2016-03-13) 903次浏览
本人的jsp页面这样写的
<%@ page contentType=”text/html; charset=utf-8″ language=”java” %>
<!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”>
<html>
<head>
<title>测试</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″>
</head>
<body>
<br>
<form id=”form1″ name=”form1″ action=”action.jsp” method=”post” enctype=”multipart/form-data”>
<table width=”96%” border=”0″ align=”center” cellpadding=”0″ cellspacing=”0″>
<tr>
<td align=”right”>名称:</td>
<td colspan=”9″ align=”left”><input type=”text” id=”name” name=”name” size=”79″/></td>
</tr>
<tr>
<td align=”right”>简介:</td>
<td colspan=”9″ align=”left”>
<textarea id=”summary” name=”summary” rows=”6″ cols=”70″></textarea>
</td>
</tr>
<tr>
<td align=”right”>文件:</td>
<td colspan=”9″ align=”left”>
<input type=”file” name=”file” size=”50″ />
</td>
</tr>
<tr>
<td colspan=”10″ align=”center”>
<input type=”submit” value=”保存” />
</td>
</tr>
</table>
</form>
</body>
</html>
解决方案

2

用data=new String(data.getBytes(“iso8859-1″),”utf8”);转换一下看看

2

貌似那个只是设置的页面的字符集是UTF-8,和提交没什么关系,提交之后假如是乱码还需要转码!

2

你提交到哪了?Servlet端处理编码类型了吗

2

后台也贴出来看看呢

2

request.setCharacterEncoding(“utf8”);
response.setCharacterEncoding(“utf8”);

2

引用:

request.setCharacterEncoding(“utf8”);
response.setCharacterEncoding(“utf8”);
?[/quote在接收页面

10

引用:

你提交到哪了?Servlet端处理编码类型了吗

+1


CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明jsp 提交表单以什么编码格式提交,都设置utf-8了为什么提交到后来是乱码
喜欢 (0)
[1034331897@qq.com]
分享 (0)