jsp 提交表单中文问题解决

    用过虑器,但只对post有效,get方式请看。http://www.blogjava.net/chenlb/archive/2007/07/17/130922.html

1.用tomcat里面的例子(在webapps\servlets-examples\WEB-INF\classes\里把filters目录放到你的classer\下,其实只要SetCharacterEncodingFilter就可以了,在web.xml里加

<filter>     
  
<filter-name>Set Character Encoding</filter-name>     
  
<filter-class>filters.SetCharacterEncodingFilter</filter-class>     
  
<init-param>     
    
<param-name>encoding</param-name>     
    
<param-value>utf8</param-value>     
  
</init-param>     
</filter>     
 
<filter-mapping>     
    
<filter-name>Set Character Encoding</filter-name>     
    
<url-pattern>/*</url-pattern>     
 
</filter-mapping>


2.如果用spring,用spring提供的过虑器,同样在web.xml里加
<filter>  
  
<filter-name>Set Character Encoding</filter-name>  
  
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>  
  
<init-param>  
    
<param-name>encoding</param-name>  
    
<param-value>utf8</param-value>  
  
</init-param>  
</filter>  
 
<filter-mapping>  
    
<filter-name>Set Character Encoding</filter-name>  
    
<url-pattern>/*</url-pattern>  
 
</filter-mapping>


展开阅读全文

没有更多推荐了,返回首页