Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

What would be right EL expression in JSP to have a new line or HTML's <br/>? Here's my code that doesn't work and render with ' ' in text.

<af:outputText value="#{msg.TCW_SELECT_PART_ANALYSIS}
#{msg.TCW_SELECT_PART_ANALYSIS2}"/>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
451 views
Welcome To Ask or Share your Answers For Others

1 Answer

Since you want to output <br />, just do:

<af:outputText value="#{msg.TCW_SELECT_PART_ANALYSIS}<br />#{msg.TCW_SELECT_PART_ANALYSIS2}" escape="false" />

The attribute escape="false" is there to avoid the <br /> being HTML-escaped.

You can even display the two messages in separate tags and put the <br /> in plain text between them.

<af:outputText value="#{msg.TCW_SELECT_PART_ANALYSIS}" />
<br />
<af:outputText value="#{msg.TCW_SELECT_PART_ANALYSIS2}" />

If you're still on JSF 1.1 or older, then you need to wrap plain HTML in <f:verbatim> like:

<f:verbatim><br /></f:verbatim>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...