Unescaped Text with th:utext

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

Unescaped Text with th:utext

tixe
a few questions:

when using th:utext for messages with something like <ul><li>bla bla</li></ul> it just does not seem to work.

i don't know why though.

i'm using legacyhtml5, could that be?

plus, if i use th:utext with messages that do not include html tags, it doesn't show them.
Reply | Threaded
Open this post in threaded view
|

Re: Unescaped Text with th:utext

Zemi
Administrator
Processor th:text works OK with HTML tags.

Could you post a code snippet?

If the message comes from a model variable, maybe the model variable is not set.
If the message comes from an i18n key, maybe you are using ${ } syntax instead of #{ }.

Reply | Threaded
Open this post in threaded view
|

Re: Unescaped Text with th:utext

tixe
jobs.position.text=Lorem ipsum dolor<ul><li>sit amet consectetuer</li><li>adipiscing elit sed diam nonummy</li></ul>nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi

and then
    <div class="be-base-block">
      <h3 class="about-name" th:text="#{jobs.position1.title}"></h3>
      <p th:utext="#{jobs.position.text}"></p>
    </div>


should i add, i'm using thymeleaf with spring and trying this locally with jetty.
Reply | Threaded
Open this post in threaded view
|

Re: Unescaped Text with th:utext

Zemi
Administrator
That should work.

If you use th:text for the same key, does it print the escaped text?

          <p th:text="#{jobs.position.text}"></p>

Reply | Threaded
Open this post in threaded view
|

Re: Unescaped Text with th:utext

tixe
yes it does.i don't know what' wrong.
a previous key (same style) works as expected.

will keep trying. thanks.
Reply | Threaded
Open this post in threaded view
|

Re: Unescaped Text with th:utext

tixe
i'm also wondering if it's not something to do with spring localeResolver or localeChangeInterceptor.

weird things happen when i change language or just click reload.

i now see the bullet points but no text in any language i try
Reply | Threaded
Open this post in threaded view
|

Re: Unescaped Text with th:utext

tixe
still happening.

i anonymized it a little.

you can have a look https://github.com/mfirry/cmon
Reply | Threaded
Open this post in threaded view
|

Re: Unescaped Text with th:utext

Zemi
Administrator
Hello again,

I downloaded and run your demo projects and I'm sorry to say that it works OK.

That's a screenshoot:

Reply | Threaded
Open this post in threaded view
|

Re: Unescaped Text with th:utext

tixe
are you running it through jetty? what container are you using?
Reply | Threaded
Open this post in threaded view
|

Re: Unescaped Text with th:utext

Zemi
Administrator
No, I run it with Tomcat 7.0.32 on Java 1.7.0_09 64 bits.
Reply | Threaded
Open this post in threaded view
|

Re: Unescaped Text with th:utext

Zemi
Administrator
It could be something related with locale. Have you tried changing your browser locale to English?
Reply | Threaded
Open this post in threaded view
|

Re: Unescaped Text with th:utext

tixe
could you try running mvn jetty:run and see if it works?
Reply | Threaded
Open this post in threaded view
|

Re: Unescaped Text with th:utext

Zemi
Administrator
Sorry, I'm not familiar with Jetty, should the URL be http://localhost:9999/v2/terms-of-service? It raises a "not found" Jetty error.


Reply | Threaded
Open this post in threaded view
|

Re: Unescaped Text with th:utext

tixe
sorry. my bad. could you git pull it and try again?

http://localhost:9991/
Reply | Threaded
Open this post in threaded view
|

Re: Unescaped Text with th:utext

Zemi
Administrator
Do you mean that you made some changes to the app?

'git pull' updates nothing.
Reply | Threaded
Open this post in threaded view
|

Re: Unescaped Text with th:utext

tixe
(going crazy today. sorry.) try now
Reply | Threaded
Open this post in threaded view
|

Re: Unescaped Text with th:utext

Zemi
Administrator
Ok, running with Jetty but everything works OK.

I also tried to change the locale to italian, but it works OK too.

I assume that the th:utext that is not working for you is

   <p th:utext="#{terms-of-service.text2}"></p>

Reply | Threaded
Open this post in threaded view
|

Re: Unescaped Text with th:utext

tixe
yes terms-of-service.text2

does not work for me (on firefox and chrome both in english)


don't know what to do.
Reply | Threaded
Open this post in threaded view
|

Re: Unescaped Text with th:utext

Zemi
Administrator
I really don't know. Your code is OK for sure.

Which JVM are you using?

Reply | Threaded
Open this post in threaded view
|

Re: Unescaped Text with th:utext

tixe
locally on my mac
java version "1.6.0_37"
Java(TM) SE Runtime Environment (build 1.6.0_37-b06-434-11M3909)
Java HotSpot(TM) 64-Bit Server VM (build 20.12-b01-434, mixed mode)


on our ubuntu servers
java version "1.6.0_22"
Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
Java HotSpot(TM) Client VM (build 17.1-b03, mixed mode, sharing)
12