Struts2 component corrupts non-english characters(Chinese)
I attempted to create a struts2 component using jsp,and I used UTF-8 header in both jsp pages,but in final result I see that those symbols came corrupted. If I change UTF-8 into GBK,it will be ok,I want to kown the reason why 'UTF-8' doesn't work, thanks!!! Struts version 2.1.8
<%@ page contentType="text/html; charset=UTF-8" language="java" import="java.util开发者_高级运维.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
componentTag.jsp
<s:component template="mytemplate.jsp">
<s:param name="list" value="{'java程序设计','Ajax完全学习手册','Struts2学习手册'">
</s:param>
</s:component>
mytemplate.jsp (/WebRoot/template/xhtml)
<div style="background-color:#eeeeee;" >
<b>JSP自定义模板</b><br/>
图书列表:<s:select list="parameters.list"></s:select>
</div>
set the JVM boot parameter of -Dfile.encoding=utf-8 MyEclipse (MyEclipse->preferences->servers->chose your version and then chose JDK to set the boot parameters)
you may try add these to your struts.xml
struts.locale=zh_CN
struts.i18n.encoding=UTF-8
if not specified in struts.xml or struts.properties struts2 will pick the encoding of your platform(of widows it is gbk by default)
很高兴遇见你
精彩评论