首先给你们看下我可以考虑到的问题:
我struts.xml配置了:<constant name="struts.i18n.encoding" value="UTF-8"></constant>
我数据库用的也是utf-8;
我jsp也是写了:
<%@ page contentType="text/html; charset=UTF-8"%>(这个写不写都乱码)
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
我web.xml是这么配置的:
<!-- spring 监听器 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- ecoding filter -->
<filter>
<filter-name>EcodingFilter</filter-name>
<filter-class>com.oa.util.EcodingFilter</filter-class>
<init-param>
<param-name>encode</param-name>
<param-value>utf-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>EcodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- spring 编码 -->
<filter>
<filter-name>encodingFilter</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>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- sturts过滤器 -->
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
<filter>
<filter-name>strutsFilterDispatcher</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>strutsFilterDispatcher</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
但是任然乱码~~~~~实在是受不了!我几乎已经把网上能改的都改了,求大神和好人帮助啊
------解决方案--------------------
你的com.oa.util.EcodingFilter如何写的
------解决方案--------------------
1.请检查TOMCAT CONFIG文件编码格式是否UTF-8
2.浏览器里面设置是否以UTF-8解析,好像是<MEAT>标签里面设置context-type="charset:utf-8" 类似这样的
3.查看自己的浏览器读取的时候是否是UTF-8 点击反键 字符串编码格式
------解决方案--------------------
可以考虑数据库里面设置是什么格式~