com.jfw.web.filter
Class CharsetFilter

java.lang.Object
  extended by com.jfw.web.filter.JFWFilter
      extended by com.jfw.web.filter.CharsetFilter
All Implemented Interfaces:
javax.servlet.Filter

public class CharsetFilter
extends JFWFilter

Set the character encoding of request. If posted data are in UTF-8 then the character encoding of request must be set before Struts starts manage the data.

Add this lines to web.xml for activate the filter.

 <filter>
   <filter-name>Charset Filter</filter-name>
   <filter-class>com.jfw.web.filter.CharsetFilter</filter-class>
     <init-param>
       <param-name>requestEncoding</param-name>
       <param-value>UTF-8</param-value>
     </init-param>
     <init-param>
       <param-name>excludeUrls</param-name>
       <param-value>action1.do;action2.do</param-value>
     </init-param>
 </filter>

 <filter-mapping>
   <filter-name>Charset Filter</filter-name>
   <url-pattern>/*</url-pattern>
 </filter-mapping>
 
If requestEncoding not declared then the default value is UTF-8.
Parameter excludeUrls is optional. Using this parameter you can exclude some actions/urls to be process by this filter. The values are separated by ";". You don't have to add all the url: only the part after last "/" must be given.


Field Summary
 
Fields inherited from class com.jfw.web.filter.JFWFilter
className, config
 
Constructor Summary
CharsetFilter()
           
 
Method Summary
 void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain next)
          Filter implementation.
 void init(javax.servlet.FilterConfig config)
          Read init parameters.
 
Methods inherited from class com.jfw.web.filter.JFWFilter
destroy, getFilterConfig, setFilterConfig
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CharsetFilter

public CharsetFilter()
Method Detail

init

public void init(javax.servlet.FilterConfig config)
          throws javax.servlet.ServletException
Read init parameters.

Parameters:
config - a FilterConfig object.
Throws:
javax.servlet.ServletException

doFilter

public void doFilter(javax.servlet.ServletRequest request,
                     javax.servlet.ServletResponse response,
                     javax.servlet.FilterChain next)
              throws java.io.IOException,
                     javax.servlet.ServletException
Filter implementation.

Parameters:
request - a ServletRequest object.
response - a ServletResponse object.
next - a FilterChain object.
Throws:
java.io.IOException
javax.servlet.ServletException