后台传值中文,前台乱码,怎么解决
发布网友
发布时间:2023-07-07 08:27
我来回答
共1个回答
热心网友
时间:2024-12-04 11:25
首先:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
并且
request.setCharacterEncoding("gb2312");
第二:
配置 server.xml。
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8" />
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" URIEncoding="UTF-8"/>
第三:
配置 web.xml
<filter>
<filter-name>setEncoding</filter-name>
<filter-class>com.dinner.filter.CharsetFilters</filter-class>
<init-param>
<param-name>coding</param-name>
<param-value>UTF-8</param-value>
</init-param>