Property of struts2 escapeHtml property not working, am I missing something?

The following code does not work correctly. I would like to take the next java line from bean

String statusMsg = "Hello World! <br/><br/><h3>Test</h3>" 

And output it with HTML tags that are not escaped.

 <s:property escapeHtml="false" value="bean.statusMsg" 

The result of this Tag and String property is that the HTML tags are still escaping, am I missing something?

My goal is to ultimately create a state data table and display it on the page, is this the wrong way to use a property tag? Thank you in advance for your help.

Current output next

 Hello World! <br/><br/><h3>Test</h3> 

I would like it to use tags and add a couple of new lines and do Test a header. This is all test code right now, just trying to get it to work.

+4
source share
1 answer

Can you try something like

 <s:property escape="false" value="bean.statusMsg"/> 

According to my knowledge. If you use a regular Struts property element to display data, it will exit the html code. Therefore, you must turn off escaping:

More details ...

Struts2 Property Tag

Update

I tried the property and its work is excellent anyway. I tried this in two ways, creating a property in my Action class, and also creating a bean and the same property inside a bean

than I used escapeHtml and it worked great in both cases. Also, if you want to display the data and show it in a formatted way, I doubt that this is the right way to do this. My suggestion is to use some CSS / HTML in your JSP to format the output, rather than getting help from the property tag

To look at the problem, specify your action code and JSP classes.

+7
source

Source: https://habr.com/ru/post/1383895/


All Articles