本人环境是jdk1.5,struts1。3,hibernate3.0,spring2.0.
项目启动一切正常,提交时出现中文乱码,用网上查的方法似乎不灵,报以下错误:
2010-2-1 16:49:32 org.apache.coyote.tomcat5.CoyoteRequest setCharacterEncoding
警告: PWC4011:由于已读取请求参数或已调用 ServletRequest.getReader(),因此无法将请求字符编码从上下文 /kitiyWeb 设置为 GBK
2010-2-1 16:49:57 com.sun.enterprise.server.logging.SystemOutandErrHandler$LoggingByteArrayOutputStream flush
信息:
我单独写了一个类继承了ActionServlet,用于设置编码。代码如下:
*/
/* */public class KitiySetEncoding extends ActionServlet
/* */{
/* */private static final long serialVersionUID = 1L;
/* */protected void process(HttpServletRequest request,
HttpServletResponse response)
/* */throws IOException, ServletException
/* */{
//System.out.println("..........." + request.getCharacterEncoding());
request.setCharacterEncoding("GBK");
super.process(request, response);
}
web。xml文件已设置
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>tool.KitiySetEncoding</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
。
form里取到的中文是乱码,手工可转换
System.out.println("...ttt=" + logonForm.getUserpins());输出是乱码
System.out.println("...ttt=" + new String(logonForm.getUserpins().getBytes("ISO-8859-1"),"GBK"));输出是正确的。
帮忙解答一下,感谢!
项目启动一切正常,提交时出现中文乱码,用网上查的方法似乎不灵,报以下错误:
2010-2-1 16:49:32 org.apache.coyote.tomcat5.CoyoteRequest setCharacterEncoding
警告: PWC4011:由于已读取请求参数或已调用 ServletRequest.getReader(),因此无法将请求字符编码从上下文 /kitiyWeb 设置为 GBK
2010-2-1 16:49:57 com.sun.enterprise.server.logging.SystemOutandErrHandler$LoggingByteArrayOutputStream flush
信息:
我单独写了一个类继承了ActionServlet,用于设置编码。代码如下:
*/
/* */public class KitiySetEncoding extends ActionServlet
/* */{
/* */private static final long serialVersionUID = 1L;
/* */protected void process(HttpServletRequest request,
HttpServletResponse response)
/* */throws IOException, ServletException
/* */{
//System.out.println("..........." + request.getCharacterEncoding());
request.setCharacterEncoding("GBK");
super.process(request, response);
}
web。xml文件已设置
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>tool.KitiySetEncoding</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
。
form里取到的中文是乱码,手工可转换
System.out.println("...ttt=" + logonForm.getUserpins());输出是乱码
System.out.println("...ttt=" + new String(logonForm.getUserpins().getBytes("ISO-8859-1"),"GBK"));输出是正确的。
帮忙解答一下,感谢!