读书人

jsp页面交付乱码

发布时间: 2013-04-27 11:15:10 作者: rapoo

jsp页面提交乱码
用的是struts2..获取用的是el表达式.提交方式是post
网上说的用的过滤器什么的都试过了...还是不行..
麻烦各位指定一下..

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@taglib uri="/struts-tags" prefix="s" %>
<%-- <%
response.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=UTF-8");
%> --%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">


<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

</head>

<body>
<form action="admin/Notice-update" method="post">
<input type="hidden" name="notice.id" value="<s:property value="notice.id"/>" />
标题:<input name="notice.title" value="<s:property value="notice.title"/>" />
文章内容:<textarea name="notice.content"><s:property value="notice.content"/></textarea>
<input type="submit" value="update" />
</form>
</body>
</html>
乱码 jsp el表达式 UTF-8 HTML
[解决办法]
post提交:
luanma=new String(luanma.getBytes("iso8859-1"),"utf8");
[解决办法]
在服务器端调用request.getParameter()方法之前用request.setCharacterEncoding("UTF-8");
[解决办法]
什么样的乱码?
[解决办法]
前台你已经做处理了,后台把转换字符编码去掉看看

读书人网 >Java Web开发

热点推荐