struts 显示中文问题 我用STRUTS框架做了个论坛,在后台输入数据,然后在前台就可以显示了,输入英文时一切正常,但是输入中文,前台就会出现乱码,但是在MYSQL里却还是显示中文,请教各位怎么解决 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 乱码问题,在页面中设定编码,不如"GBk" 你把提交方式改下,把get改为post试下。 写一个编码过滤器,懒的话就复制tomcat自带的就可以,要配置一下web.xmlpublic 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>com.cn.nst.filter.SetCharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> </filter><filter-mapping> <filter-name>Set Character Encoding</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> list转换 XFIRE框架的问题 JDK1.7部分新特性用不了咋回事? openflashchart 统计 我今天在做一个socket的通信程序 报如下错 请问是什么原因 这的框架关于tapestry的东西怎么这么少? 请教高手 Struts+Spring+Hibernate 的上传下载 winrar解压缩出现的问题 哪位大哥知道jsp怎样批量生成html文件呀,帮兄弟一把,分之不够可一再加!!!! AXIS能不能说是一种J2EE下的Web Services实现 JavaScript中能用JSP重定向吗? 缓存
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>com.cn.nst.filter.SetCharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>Set Character Encoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>