Problems with html entities

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Problems with html entities

Cesarvv
Hi. I have this code: <input th:value="${proForm.getDescripcion()}" />
The value of proForm.getDescripcion() is: &amp;&lt;&gt;
But Thymeleaf 3.0.3 gives me this output:
<input value="&amp;amp;&amp;lt;&amp;gt;" />
I know that thymeleaf internally converts it. How do I disable this function in Thymeleaf? Thanks!
Reply | Threaded
Open this post in threaded view
|

Re: Problems with html entities

Metroids
When you submit the form, do you want the new value of proForm.getDescripcion() to be
&<>
?

If you want it still to be
 &amp;&lt;&gt;
 after submission, then thymeleaf is doing the right thing.

I don't think there is any easy way to get thymeleaf to do what you want it to do...  Unless you do some conversion in your java code.
Reply | Threaded
Open this post in threaded view
|

Re: Problems with html entities

Cesarvv
When the form is submitted, it is ok. When I recover the value is the problem
Reply | Threaded
Open this post in threaded view
|

Re: Problems with html entities

Metroids
The point is, you have to choose either:

Object:
&amp;&lt;&gt;
Form:
&amp;amp;&amp;lt;&amp;gt;

OR

Object:
&<>
Form:
&amp;&lt;&gt;


There is no way to have:

Object:
&amp;&lt;&gt;
Form:
&amp;&lt;&gt;

Both because of the way thymeleaf works, and because of the way browsers understand htmlentitites.  If you tried to do this:

Object:
&amp;&lt;&gt;
Form:
&amp;&lt;&gt;

When you submit the form, you would save
&<>
 to the value. (Which is different from the original value, even though nothing changed).
Reply | Threaded
Open this post in threaded view
|

Re: Problems with html entities

Cesarvv
In the database I should save like this:
&amp;&lt;&gt;

:(