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).
分享到:
相关推荐
org.springframework.web.filter.CharacterEncodingFilter.class org.springframework.web.filter.CommonsRequestLoggingFilter.class org.springframework.web.filter.DelegatingFilterProxy.class org.spring...
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java...
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java...
例如,`org.springframework.web.filter.CharacterEncodingFilter`是一个预设的过滤器,用于确保请求和响应的字符编码一致。我们可以在`filter-mapping`标签中指定哪些URL应该经过此过滤器。 3. **处理请求...
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <param-name>encoding <param-value>UTF-8 <param-name>forceRequestEncoding <param-value>true ...
org.springframework.web.filter.CharacterEncodingFilter </filter-class> <param-name>encoding <param-value>UTF-8 </filter> <filter-mapping> <filter-name>setCharacterEncoding</filter-name> ...
org.springframework.web.context.ContextLoaderListener ``` 这段代码指定了一个Listener类`ContextLoaderListener`,该类由Spring框架提供,用于在应用程序启动时加载Spring的上下文配置。 #### Filter ...
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <param-name>encoding <param-value>UTF-8 <param-name>forceEncoding <param-value>true </filter> <filter...
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <param-name>encoding <param-value>UTF-8 </filter> <filter-mapping> <filter-name>CharacterFilter</filter-...
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <param-name>encoding <param-value>UTF-8 <param-name>forceEncoding <param-value>true </filter> <filter...
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @Controller public class HelloWorldController { @RequestMapping(value = ...
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <param-name>encoding <param-value>GBK </filter> <filter-mapping> <filter-name>...
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <param-name>encoding <param-value>UTF-8 </filter> <filter-mapping> <filter-name>characterEncodingFilter</...
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <param-name>encoding <param-value>utf-8 </filter> <filter-mapping> <filter-name>...
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <param-name>encoding <param-value>UTF-8 </filter> <filter-mapping> <filter-name>characterEncodingFilter</...
org.springframework.web.filter.CharacterEncodingFilter </filter-class> <param-name>encoding <param-value>UTF-8 </filter> <filter-mapping> <filter-name>encodingFilter</filter-name...
cannot be cast to javax.servlet.Filter 报错, 原因servlet-api.jar冲突 使用maven开发web应用程序, 启动的时候报错: jar not loaded....java.lang.ClassCastException: org.springframework.web.f