标签:struts2 乱码 编码 tomcat struts
1.设置struts的字符编码,可以在struts.xml中增加以下代码:
<constant name="struts.i18n.encoding" value="GBK" />
### This can be used to set your default locale and encoding scheme # struts.locale=en_US struts.i18n.encoding=GBK
2.设置JSP页面字符编码:
<%@ page language="java" contentType="text/html; charset=GBK" pageEncoding="GBK"%>
<Connector URIEncoding="GBK" connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443" />
public static String changeEncoding(String s, String oldEncoding, String newEncoding) { String result = null; try { result = new String(s.getBytes(oldEncoding), newEncoding); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return result; }
标签:struts2 乱码 编码 tomcat struts
原文地址:http://blog.csdn.net/sinat_19425927/article/details/39345501