MyException - 我的异常网
当前位置:我的异常网» Java Web开发 » jsp页面展示中文

jsp页面展示中文(3)

www.MyException.Cn  网友分享于:2013-11-17  浏览:65次

this.ignore = true;
else if (value.equalsIgnoreCase( "true "))
this.ignore = true;
else if (value.equalsIgnoreCase( "yes "))
this.ignore = true;
else
this.ignore = false;

}


// ------------------------------------------------------ Protected Methods


/**
* Select an appropriate character encoding to be used, based on the
* characteristics of the current request and/or filter initialization
* parameters. If no character encoding should be set, return
* <code> null </code> .
* <p>
* The default implementation unconditionally returns the value configured
* by the <strong> encoding </strong> initialization parameter for this
* filter.
*
* @param request The servlet request we are processing
*/
protected String selectEncoding(ServletRequest request) {

return (this.encoding);

}


}
以上代码可以完全拷贝或者修改类名或包名为你自己的类名,如com.somecompany.filter.SetCharacterEncodingFilter
第二步,配置你的web.xml,加入一下过滤器的内容
<filter>
<filter-name> setCharacterEncoding </filter-name>
<filter-class> com.somecompany.filter.SetCharacterEncodingFilter </filter-class>
<init-param>
<param-name> encoding </param-name>
<param-value> GBK </param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name> setCharacterEncoding </filter-name>
<url-pattern> /* </url-pattern>
</filter-mapping>
注意:如果你的web。xml里有其他过滤器的话,为了解决中文,最好将此段内容拷贝到其他过滤器的前面。有了这个过滤器,你就不用担心中文问题了e
------解决方案--------------------
<Connector
后面加 URIEncoding= "GBK " />

文章评论

软件开发程序错误异常ExceptionCopyright © 2009-2015 MyException 版权所有