Struts 2 escape html doesn't work?

限于喜欢 提交于 2021-02-08 09:12:36

问题


I have a Struts2 problem,

<s:property escape="false" value="value" />

value is got from database, content html tags, Example:

TOTO<br/>Adresse:<br/>

when using Struts2 tag with escape false the result: TOTO<br/>Adress:<br/> and not the well formatted content, so anyone has an idea how to correct this? I try escapeHhtml, escapeXML, escape, always same problem... the result that I want is like:

TOTO
Adress:

回答1:


Try the code in the action

public String getValue(){
  return StringEscapeUtils.unescapeHtml4(this.value);
}

then use with

<s:property escapeHtml="false" value="value" />


来源:https://stackoverflow.com/questions/27797431/struts-2-escape-html-doesnt-work

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!