解决 jsp include 参数乱码

解决 jsp include 参数乱码

今天碰到一个这样的问题,我开始用了n个原始的方法都解决不了。我就以为这过滤器中也解决不了。没想到一试就灵,
这也是解决jsp include 参数乱码最有效的方式,网上别的方式不一定能行。

public   class  MyFilter  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()  {
    }

}

web.xlm配置
< filter >  
< filter - name > MyFilter </ filter - name >  
< filter - class > com.lx.MyFilter </ filter - class >  
</ filter >  
< filter - mapping >  
< filter - name > MyFilter </ filter - name >  
< url - pattern > /**/ /* </url-pattern> 
<dispatcher>request</dispatcher> 
</filter-mapping>

你可能感兴趣的:(解决 jsp include 参数乱码)