I used all "utf-8" encoding for my jsp pages .
I used struts2 as my web framework and ran it on a tomcat.
Recently, I found that part of Chinese characters were garbled and the remainder where normal.
Plz take a look at the below pics:
This picture is about the output html source code. Here, the content of the data-tmpl attribute of the link must be the same as div content above.
But it was not, and there part of the content were garbled.
Here are the jsp codes:
page encoding:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
the logic code of the picture above:
<div class="float-left ${st.odd?'odd':'even'}" >
${template }【${signNoBracket }】
</div>
<a class="sms-editor-select-tmpl float-right" data-tmpl="${template }" data-sign="${signNoBracket }" href="###" style="display:none;">使用</a>
<p class="clear"></p>
this jsp page was include by a parent jsp page by:
<s:include value="/controls/2.0/sms-editor.jsp"></s:include>
The ref of 'template' are all the same by using EL expression.
So why could this happen? Is there any problem with tomcat output encoding?
add at 2013-11-1 0:25:02
Hi all, this days I do some experiment to find that either tomcat or struts framework lead to this problem occur.
I use jsp scripts to instead el expression, the problem still exist.
Here are some code snaps:
<%
ValueStack vs = TagUtils.getStack(pageContext);
Object value = vs.findValue("template");
System.out.println(value);
%>
<a class="sms-editor-select-tmpl float-right" data-tmpl="<%=value %>" data-sign="${signNoBracket }" href="###" style="display:none;">使用</a>
And I can see the value println in tomcat console, it is normal as we expected. So, there must be some bugs in tomcat output stream of chinese character.
the tomcat's output (it is very normal):
#收货人#您好,看到您给的中差评,抱歉让您有了不满意的购物经历。若可以我们愿意承担运费为您提供退货,希望旺旺联系我们!
I test my application on two version of tomcat, they all have this problem. One is apache-tomcat-6.0.30 and the other one is apache-tomcat-7.0.47 .
So, is there any body can help me solve this problem? Or just show me the way.
now I try jetty 9.0.6 to run my application, the problem still exist.... Who can tell me what the hell....
OTL orz !!!