请报上
你的系统,jdk版本,tomcat版本。
服务器的系统,jdk版本,tomcat版本。
你的系统,jdk版本,tomcat版本。
服务器的系统,jdk版本,tomcat版本。
解决方案 »
- jasperReport ,用过的来帮个忙
- jap过滤器的问题
- java软件开发
- 急!!soap包的名空间可以改吗,怎么改
- div标签和span标签有什么区别?
- web服务如何读取配置诸如web.xml中的数据?
- !!!求助。socket通信之eofexception!!!
- 请举个例子说明如何设计EJB架构?
- 我的机器装了个Oracle9i之后,为什么程序都不能运行了?100分求教!
- JSON报错:can not access a member of class * with modifiers "public"
- tomcat 4.0 在那下载呀
- ~~怎样设置jTable中的某一列不可编辑~~
jsp 上面用上这句吧
二、提交的数据乱码 现象:通过表单提交的数据出现乱码。 原因:原因未明。可能是Tomcat在接收到请求后,并没有能够根据request中的信息提前正确的编码方式。 解决:可以添加一个设置字符集的Filter。package filters;import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.UnavailableException;public class SetCharacterEncodingFilter implements Filter {
protected String encoding = null;
protected FilterConfig filterConfig = null;
protected boolean ignore = true; public void destroy() {
this.encoding = null;
this.filterConfig = null;
}public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain)
throws IOException, ServletException { // Conditionally select and set the character encoding to be used
if (ignore || (request.getCharacterEncoding() == null)) {
String encoding = selectEncoding(request);
if (encoding != null)
request.setCharacterEncoding(encoding);
} // Pass control on to the next filter
chain.doFilter(request, response);}public void init(FilterConfig filterConfig) throws ServletException { this.filterConfig = filterConfig;
this.encoding = filterConfig.getInitParameter("encoding");
String value = filterConfig.getInitParameter("ignore");
if (value == null)
this.ignore = true;
else if (value.equalsIgnoreCase("true"))
this.ignore = true;
else if (value.equalsIgnoreCase("yes"))
this.ignore = true;
else
this.ignore = false;}protected String selectEncoding(ServletRequest request) {
return (this.encoding);
}} 配置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>GBK</param-value>
</init-param>
</filter><filter-mapping>
<filter-name>Set Character Encoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>