问题
I am trying to populate name text field with already saved value.
Now the value can contain apostrophe. But text fields is converting apostrophe to "' ;
".
Eg. sdsd'sds
==> sdsd' ;sds
escape
property for textfield is not working.
What should I do?
回答1:
You are getting this because of Encoding feature.
To avoid this and get exactly same as you want, you have to use HtmlDecode
which is available in util package of java.
回答2:
You are probably escaping it server-side.
Don't.
Struts will take care of this.
You only need to specify when you want the opposite (getting the unescaped value in the <s:property />
tag) using the escapeHtml="false"
property.
P.S: there are characters that need a special threatment like the € (euro symbol), but it's another story.
回答3:
This issue got resolved with use of ESAPI.encoder().decodeForHTML() function. The values getting rendered properly after I decode the values before using in s:textfields.
Thanks.
来源:https://stackoverflow.com/questions/34436841/struts-2-textfield-convert-apostrophe-to-39