修改struts2.xml
struts2.xml 中添加
<constant name="struts.i18n.encoding" value="UTF-8"></constant>
配置jsp页面
jsp页面加入
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
配置Spring的web.xml
在web.xml 加入针对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> <init-param> <param-name>forceEncoding</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
修改TOMCAT配置
修改tomcat的 /conf/server.xml中的
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443">
为
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443" URIEncoding="UTF-8" useBodyEncodingForURI="true" />
时间: 2024-10-05 23:27:09