我想在兩線在Struts2插入在Struts2 messages.properties新線
User Name is not valid
Password is not valid
顯示錯誤消息,我的屬性是:
username.password.errrorMsg: User Name is not valid \n Password is not valid.
我加\n
但其在單顯示線。
你能建議以兩行顯示嗎?
我想在兩線在Struts2插入在Struts2 messages.properties新線
User Name is not valid
Password is not valid
顯示錯誤消息,我的屬性是:
username.password.errrorMsg: User Name is not valid \n Password is not valid.
我加\n
但其在單顯示線。
你能建議以兩行顯示嗎?
如果使用消息格式,則使用\n
符號添加一個新的行字符。如果你想顯示actionerror
或actionmessage
標籤這個消息你需要使用<br>
並讓它不能逃脫。例如
<s:actionmessage escape="false"/>
感謝羅馬,我只是將
放在屬性文件中並使用在jsp中,它的工作非常感謝 - –
sree
因爲換行/打破字符取決於你在哪裏使用/顯示消息,最好使用不同的消息。
invalid.userName = User Name is not valid
invalid.password = Password is not valid
通過這種方式,你可以分開使用的情況下,你想顯示具體的消息,只要你想顯示他們。
如果您在HTML/JSP使用S2 <s:text>
標籤然後<br/>
應該工作顯示它們。但是有幾個標籤正在轉義HTML,例如在<s:property>
和getText()
中使用這種消息,則需要將escapeHTML
屬性設置爲false。
不這樣做。使用單獨的消息。 –
感謝Aleksandr,我使用了分離的消息,我可以知道爲什麼我們需要使用單獨的消息嗎? – sree