Suppose name contains non-ascii characters, when I use <s:property value="name" />, Struts automatically converts those characters to things like 仅.
This is completely unnecessary as I declares
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>`
and
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
and
struts.i18n.encoding=UTF-8
It makes the html source completely unreadable on client side while increasing the size of the page tremendously.
I know <s:property value="name" escapeHtml="false" /> could solve my problem. But that’s not the point. This option is intended to be used when I don’t want escapeHtml at all. What I want is escape Html properly while leaving UTF-8 characters alone! I guess setting a property somewhere should solve the problem, but where? I searched for quite a long time and can’t find a solution.
This is something specific to the
<s:property/>tag. You can use<c:out/>instead, which will escape XML characters without altering the Unicode characters. Try this:This is the JSTL equivalent of
<s:property value="name"/>.