问题
How to insert a new line between words for a backing bean value and display it on UI using JSF 2.0 framework? If we have address. The street name should be in first line and city and state should be in the second line. I am using a converter to add new line. But it does not show up on the UI.
回答1:
JSF is basically a HTML code generator. A new line is in HTML to be presented by the <br />
tag, not by \r\n
characters or something. You can just do it straight in the view instead of mingling view-specific details in the managed bean or a converter.
<h:outputText value="#{user.address.street} #{user.address.houseNumber}" />
<br />
<h:outputText value="#{user.address.city}, #{user.address.state}" />
来源:https://stackoverflow.com/questions/7853790/insert-new-line-in-a-backing-bean-string-value