web.xml设置编码

    <filter>
        <filter-name>CharacterFilter</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>CharacterFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

设置request编码为utf-8

还可以在<filter>节点中添加

<init-param>
            <param-name>forceEncoding</param-name>
            <param-value>true</param-value>
</init-param>

表示是否同时设置response编码

时间: 2024-08-28 19:41:23

web.xml设置编码的相关文章

web.xml文件--编码注意事项

写在前面: 最近发布项目的时候,要修改web.xml文件的内容,然后我在本机的web.xml文件中是有注释的,但是到了服务器上面,就说编码不同.我也没有怎么注意.就继续启动服务器,但是访问网站,一直报错.很是郁闷,拿比对工具比对两个web.xml文件的不同,除了一个注释有乱码外 ,没有任何区别.然后 我就把乱码的注释给去掉了 因为这个时候的注释在服务器上是 乱码的 因为编码不同  我不知道 编码不同造成乱码的注释 还可以有这种操作???????重启服务器 然后问题就被解决了..郁闷呀..所以.大

web.xml添加编码过滤器

解决前后台交互汉字乱码 在项目中的web.xml中添加如下代码: <filter> <filter-name>CharacterEncodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding<

spring mvc 和spring security配置 web.xml设置

<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"          xsi:schemaLocation="http://xmlns.jcp.o

web.xml配置编码过滤器

如果没有配置 1,出现中文乱码问题 2,只能查询英文,无法查询出中文 注意: 其中encoding用来设置编码格式,forceEncoding用来设置是否理会 request.getCharacterEncoding()方法,设置为true则强制覆盖之前的编码格式. <!-- 配置字符编码过滤器 --> <filter> <filter-name>encoding</filter-name> <filter-class>org.springfra

Java web的web-app 的web.xml 设置

<?xml version="1.0" encoding="UTF-8"?> <web-app> <!-- 1.icon --> <icon></icon> <!-- 2.display-name 定义站台的名称 --> <display-name></display-name> <!-- 3.description 是对站台的描述 --> <descr

web.xml 中以编码方式添加filter并设置初始化参数AbstractAnnotationConfigDispatchServletInitializer

web.xml中配置filter <?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=&q

在web.xml中设置全局编码

在web.xml中配置 <filter> <filter-name>characterFilter</filter-name> <filter-class>com.cn.CharacterFilter</filter-class> </filter> <filter-mapping> <filter-name>characterFilter</filter-name> <url-pattern

struts2设置index.action为主页(另:web.xml编辑卡死问题解决)

本来是弄拦截器的问题,结果弄主页的时候,还是发现了问题. 公司网站的项目里面,是用index.action作为主页的,访问WEB-INF里面的html文件.可是我设置的却不成功,追根到底,一个原因,struts2比较特殊,struts.xml里面必须多配置一个request和response. <?xml version="1.0" encoding="UTF-8"?> <web-app id="WebApp_9" versio

lisener在web.xml中设置

/* * servlet监听器开发步骤: * 1.写一个类实现XXXListener接口(6个=3个容器+3个对容器中属性进行操作) * 2.在web.xml中配置<listener> ---规范:一般写在<Filter>和<Servlet>之间 * */ <?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.or