Aryan
Aryan

Reputation: 1877

Struts 2 textfield convert apostrophe to "&#39 ;"

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 "&#39 ;".

Eg. sdsd'sds ==> sdsd&#39 ;sds

escape property for textfield is not working.

What should I do?

Upvotes: 2

Views: 888

Answers (3)

Aryan
Aryan

Reputation: 1877

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.

Upvotes: 0

Andrea Ligios
Andrea Ligios

Reputation: 50203

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.

Upvotes: 0

Rish
Rish

Reputation: 1383

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.

Upvotes: 1

Related Questions