两个jsp页面通过action传值,已经加上了
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ page pageEncoding="UTF-8" %>
struts.xml里面加上了
<constant name="struts.i18n.encoding" value="UTF-8"/>
web.xml加上了
<filter>
<filter-name>struts-cleanup</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ActionContextCleanUp
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts-cleanup</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
在action里面加上了
public String execute() throws Exception {
// TODO Auto-generated method stub
HttpServletRequest request= null;
HttpServletResponse response = null;
request = ServletActionContext.getRequest();
response = ServletActionContext.getResponse();
request.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
return "success";
}
并且在struts.xml的同级文件夹下建立了struts.properties文件,内容如下:
struts.devMode=false
struts.enable.DynamicMethodInvocation=true
struts.i18n.reload=true
struts.ui.theme=simplestruts.locale=zh_CN
struts.i18n.encoding=UTF-8struts.serve.static.browserCache=false
struts.url.includeParams=none
为什么jsp通过action传给另一个jsp页面显示还是乱码呢?
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ page pageEncoding="UTF-8" %>
struts.xml里面加上了
<constant name="struts.i18n.encoding" value="UTF-8"/>
web.xml加上了
<filter>
<filter-name>struts-cleanup</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ActionContextCleanUp
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts-cleanup</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
在action里面加上了
public String execute() throws Exception {
// TODO Auto-generated method stub
HttpServletRequest request= null;
HttpServletResponse response = null;
request = ServletActionContext.getRequest();
response = ServletActionContext.getResponse();
request.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
return "success";
}
并且在struts.xml的同级文件夹下建立了struts.properties文件,内容如下:
struts.devMode=false
struts.enable.DynamicMethodInvocation=true
struts.i18n.reload=true
struts.ui.theme=simplestruts.locale=zh_CN
struts.i18n.encoding=UTF-8struts.serve.static.browserCache=false
struts.url.includeParams=none
为什么jsp通过action传给另一个jsp页面显示还是乱码呢?
解决方案 »
- myeclipse中找不到资源
- freemarker显示当前页面数据
- 怎么实现 word ppt excel 网页上预览
- 急求一个关于上传文件用的“选择文件”对话框代码。。
- 一个目录树的父子节点有4千多或更多,现在用以前的XTREE代码出现了读取树结构读取不出的错误.请问用什么比较好,对于数据量较大的数据量的
- JSF抛出java.lang.NullPointerException异常
- 请教:在TOMCAT里打开一个静态的页竟显示乱码,但在静态页的程序里都没有问题,已经加了GB2312了为什么还乱码?
- 请教tomcat从4.1升级到5.0.27出现的显示乱码问题
- 求hibernateTemplate 用SQL分页的代码
- java小白遇到问题,求过路大神帮帮忙!
- 获取有关客户端上次请求的URL的常规方案
- linux 下 Java乱码问题
HttpServletResponse response = null;
request = ServletActionContext.getRequest();
response = ServletActionContext.getResponse();
request.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
这些东西没必要,去掉。
检查action jsp的编码格式都是什么。
String(name.getBytes("ISO-8859-1"),"UTF-8")解决了,再去找原因,很麻烦的