SetCharacterEncodingFilter.java
资源名称:shihua.rar [点击查看]
上传用户:zghglow
上传日期:2022-08-09
资源大小:27227k
文件大小:1k
源码类别:
WEB源码(ASP,PHP,...)
开发平台:
JavaScript
- package com.chinacannel.common;
- import javax.servlet.*;
- import javax.servlet.http.*;
- import java.io.*;
- import java.util.*;
- public class SetCharacterEncodingFilter
- extends HttpServlet implements Filter {
- private FilterConfig filterConfig;
- //Handle the passed-in FilterConfig
- public void init(FilterConfig filterConfig) throws ServletException {
- this.filterConfig = filterConfig;
- }
- //Process the request/response pair
- public void doFilter(ServletRequest request, ServletResponse response,
- FilterChain filterChain) {
- try {
- request.setCharacterEncoding("GBK");
- filterChain.doFilter(request, response);
- }
- catch (ServletException sx) {
- filterConfig.getServletContext().log(sx.getMessage());
- }
- catch (IOException iox) {
- filterConfig.getServletContext().log(iox.getMessage());
- }
- }
- //Clean up resources
- public void destroy() {
- }
- }