SSH2有jsp页面传到Action的中文乱码问题
jsp页面<%@pagelanguage="java"import="java.util.*"pageEncoding="GBK"contentType="text/ht...
jsp页面
<%@ page language="java" import="java.util.*" pageEncoding="GBK" contentType="text/html;charset=GBK"%>
也写了过滤器
<filter>
<filter-name>encoding_filter</filter-name>
<filter-class>com.commons.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>GBK</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encoding_filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain)
throws IOException, ServletException {
System.out.print("\ndoFilter(ServletRequest request, ServletResponse response,FilterChain chain)\n ");
// 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);
}
前台输入的话是
<input type="text" name="client.company"
value="<%=client.getCompany()%>" />
在Action中也是直接使用client
在后台打印:System.out.print(client.getCompany()+"\n");
前台输入的中文显示为乱码
请问如何解决? 展开
<%@ page language="java" import="java.util.*" pageEncoding="GBK" contentType="text/html;charset=GBK"%>
也写了过滤器
<filter>
<filter-name>encoding_filter</filter-name>
<filter-class>com.commons.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>GBK</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encoding_filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain)
throws IOException, ServletException {
System.out.print("\ndoFilter(ServletRequest request, ServletResponse response,FilterChain chain)\n ");
// 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);
}
前台输入的话是
<input type="text" name="client.company"
value="<%=client.getCompany()%>" />
在Action中也是直接使用client
在后台打印:System.out.print(client.getCompany()+"\n");
前台输入的中文显示为乱码
请问如何解决? 展开
4个回答
展开全部
前台页面也做了<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>???
WEB
<!-- 使用spring解决struts2乱码问题 -->
<filter>
<filter-name>encoding</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
WEB
<!-- 使用spring解决struts2乱码问题 -->
<filter>
<filter-name>encoding</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
展开全部
tomcat里server.xml面找到端口
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" URIEncoding="字符集" />
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" URIEncoding="字符集" />
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
在的doFilter里面直接设置编码格式为GBK
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2012-04-07
展开全部
看下你的表单请求是不是post
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询