`
gstarwd
  • 浏览: 1522169 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

org.springframework.web.filter.CharacterEncodingFilter 配置

阅读更多

web.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
 version="2.4">

    <filter>
      <filter-name>CharacterEncodingFilter</filter-name>
      <filter-class>
           org.springframework.web.filter.CharacterEncodingFilter
      </filter-class>
      init-param>
       <param-name>encoding</param-name>
       <param-value>GB2312</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>*.jsp</url-pattern>
  </filter-mapping>

</web-app>

public class CharacterEncodingFilter
extends OncePerRequestFilter

Servlet 2.3/2.4 Filter that allows one to specify a character encoding for requests. This is useful because current browsers typically do not set a character encoding even if specified in the HTML page or form.

This filter can either apply its encoding if the request does not already specify an encoding, or enforce this filter's encoding in any case ("forceEncoding"="true"). In the latter case, the encoding will also be applied as default response encoding on Servlet 2.4+ containers (although this will usually be overridden by a full content type set in the view).

分享到:
评论
1 楼 jfzshandong 2012-12-28  

相关推荐

    spring-web-2.5.jar

    org.springframework.web.filter.CharacterEncodingFilter.class org.springframework.web.filter.CommonsRequestLoggingFilter.class org.springframework.web.filter.DelegatingFilterProxy.class org.spring...

    apache-tomcat-7.0.69.zip

    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java...

    java head space.txt

    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java...

    详解Spring mvc的web.xml配置说明

    例如,`org.springframework.web.filter.CharacterEncodingFilter`是一个预设的过滤器,用于确保请求和响应的字符编码一致。我们可以在`filter-mapping`标签中指定哪些URL应该经过此过滤器。 3. **处理请求...

    IDEASSM框架实战CRUDSSM整合配置MyBatis逆向工程.docx

    &lt;filter-class&gt;org.springframework.web.filter.CharacterEncodingFilter&lt;/filter-class&gt; &lt;param-name&gt;encoding &lt;param-value&gt;UTF-8 &lt;param-name&gt;forceRequestEncoding &lt;param-value&gt;true ...

    spring配置编码格式

    org.springframework.web.filter.CharacterEncodingFilter &lt;/filter-class&gt; &lt;param-name&gt;encoding &lt;param-value&gt;UTF-8 &lt;/filter&gt; &lt;filter-mapping&gt; &lt;filter-name&gt;setCharacterEncoding&lt;/filter-name&gt; ...

    web.xml文件中配置(servlet, spring, filter, listenr)的加载顺序

    org.springframework.web.context.ContextLoaderListener ``` 这段代码指定了一个Listener类`ContextLoaderListener`,该类由Spring框架提供,用于在应用程序启动时加载Spring的上下文配置。 #### Filter ...

    spring MVC所需jar包和filter的配置

    &lt;filter-class&gt;org.springframework.web.filter.CharacterEncodingFilter&lt;/filter-class&gt; &lt;param-name&gt;encoding &lt;param-value&gt;UTF-8 &lt;param-name&gt;forceEncoding &lt;param-value&gt;true &lt;/filter&gt; &lt;filter...

    Spring+mybatis

    &lt;filter-class&gt;org.springframework.web.filter.CharacterEncodingFilter&lt;/filter-class&gt; &lt;param-name&gt;encoding &lt;param-value&gt;UTF-8 &lt;/filter&gt; &lt;filter-mapping&gt; &lt;filter-name&gt;CharacterFilter&lt;/filter-...

    web配置文件.txt

    &lt;filter-class&gt;org.springframework.web.filter.CharacterEncodingFilter&lt;/filter-class&gt; &lt;param-name&gt;encoding &lt;param-value&gt;UTF-8 &lt;param-name&gt;forceEncoding &lt;param-value&gt;true &lt;/filter&gt; &lt;filter...

    Spring 注解学习手札

    import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @Controller public class HelloWorldController { @RequestMapping(value = ...

    SSH整合配置.doc

    &lt;filter-class&gt;org.springframework.web.filter.CharacterEncodingFilter&lt;/filter-class&gt; &lt;param-name&gt;encoding &lt;param-value&gt;GBK &lt;/filter&gt; &lt;filter-mapping&gt; &lt;filter-name&gt;...

    SpringMVC Tomcat控制台乱码问题解决方案

    &lt;filter-class&gt;org.springframework.web.filter.CharacterEncodingFilter&lt;/filter-class&gt; &lt;param-name&gt;encoding &lt;param-value&gt;UTF-8 &lt;/filter&gt; &lt;filter-mapping&gt; &lt;filter-name&gt;characterEncodingFilter&lt;/...

    javaSSH框架搭建配置

    &lt;filter-class&gt;org.springframework.web.filter.CharacterEncodingFilter&lt;/filter-class&gt; &lt;param-name&gt;encoding &lt;param-value&gt;utf-8 &lt;/filter&gt; &lt;filter-mapping&gt; &lt;filter-name&gt;...

    SSH2整合详细示例

    &lt;filter-class&gt;org.springframework.web.filter.CharacterEncodingFilter&lt;/filter-class&gt; &lt;param-name&gt;encoding &lt;param-value&gt;UTF-8 &lt;/filter&gt; &lt;filter-mapping&gt; &lt;filter-name&gt;characterEncodingFilter&lt;/...

    Spring MVC 框架应用实例

    org.springframework.web.filter.CharacterEncodingFilter &lt;/filter-class&gt; &lt;param-name&gt;encoding &lt;param-value&gt;UTF-8 &lt;/filter&gt; &lt;filter-mapping&gt; &lt;filter-name&gt;encodingFilter&lt;/filter-name...

    解决cannot be cast to javax.servlet.Filter 报错的问题

    cannot be cast to javax.servlet.Filter 报错, 原因servlet-api.jar冲突 使用maven开发web应用程序, 启动的时候报错: jar not loaded....java.lang.ClassCastException: org.springframework.web.f

Global site tag (gtag.js) - Google Analytics