Search code examples
javajspstruts2ognlstruts-tags

Escape string using Struts2 tags


I am trying to escape characters

<s:select list="#{'Achat d'eclair':'Achat d'eclair'}" />

How can I escape Achat d'eclair in Struts2 tags ?


Solution

  • First of all with #{} notation you're creating a map where value before : is a key and after is a value and you probably don't want that the key of your map would be with some complex characters in it.

    To escape ' use \\ like so:

    <s:select list="#{'achatdeclair':'Achat d\\'eclair'}" />