乱码解决方法:
一:首先从action跳转到jsp页面,即初始化页面是从action开始的,不是直接访问的jsp页面。
二:在web.xml中加入Filter(需导入sping的jar包)
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- Spring 字符集Filter -->
<filter>
<filter-name>setCharacterEncoding</filter-name>
<filter-class>
org.springframework.web.filter.CharacterEncodingFilter
</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>setCharacterEncoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
分享到:
相关推荐
Struts2乱码解决办法,个人测试有效
在struts2中解决页面中出现的乱码问题,写在web.xml中
struts2各种情况下乱码处理,设计前台,后台,数据库等配置
Textfilter源和struts.xml配置文件. 博文链接:https://flym.iteye.com/blog/183534
struts中文乱码问题解决详细步骤(两种方法)
eclipse struts 中文乱码问题图解 页面乱码 参数乱码 国际化乱码
Struts中文乱码解决方案
关于StrutsPrepareAndExecuteFilter最新的过滤器,在Struts.xml定义常量<constant name="struts.i18n.encoding" value="UTF-8"/>...关于Struts2各个版本、各种过滤器,用get方式提交都方法都无法解决的中文乱码问题。
struts 中文乱码问题解决
struts2中文乱码的解决DEMO,绝对可以运行。
Struts2资源文件在jsp页面中显示乱码解决
Struts2下载文件时中文乱码和空格处理
struts乱码解决方法struts乱码解决方法struts乱码解决方法struts乱码解决方法struts乱码解决方法struts乱码解决方法struts乱码解决方法struts乱码解决方法
struts1.2 解决中文乱码(Java技术)
struts2中文乱码
奇怪的struts2的中文乱码问题及解决.docx
struts2配置文件传值中文乱码
struts2中存在中文乱码的问题解决方 中文乱码,首先要区分是页面乱码、action乱码,还是数据库乱码。 大致的原理是java使用unicode编码-->window使用gbk(gb2312的扩展集)--mysql默认使用utf-8(unicode的一种编码...