Created
January 12, 2012 06:35
-
-
Save froop/1599078 to your computer and use it in GitHub Desktop.
[Java][Servlet] HTTP-POSTのRequestにsetCharacterEncodingするFilter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CharacterEncodingFilter implements Filter { | |
public void doFilter(ServletRequest request, ServletResponse response, | |
FilterChain chain) throws IOException, ServletException { | |
HttpServletRequest httpReq = (HttpServletRequest) request; | |
if ("POST".equalsIgnoreCase(httpReq.getMethod())) { | |
request.setCharacterEncoding("Windows-31J"); | |
} | |
chain.doFilter(request, response); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<filter> | |
<filter-name>CharacterEncodingFilter</filter-name> | |
<filter-class>sample.CharacterEncodingFilter</filter-class> | |
</filter> | |
<filter-mapping> | |
<filter-name>CharacterEncodingFilter</filter-name> | |
<url-pattern>/sample/*</url-pattern> | |
</filter-mapping> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment