I need to break line between my message thrown by custom Exception
.
I'm using Struts 2 addActionError()
and the error message will be displayed on JSP.
So here is my Java code:
if (result_Of_Scan.equals("ERROR")) {
throw new AdserverException("We are getting problem with connecting our "
+ "Antivirus Server! Please try again after some time");
}
So I need to show "We are getting problem with connecting our Antivirus Server"
on first line and "Please try again after some time"
on next line on the browser.
I have tried \\n
, <br>
and <br>
but they are not working.
To display the message on the new line in JSP you should use <br>
. It didn't display on the new line when you have tried it because <s:actionerror>
by default escapes html. You should use escape="false"
attribute to change the output to allow rendering html.
<s:if test="hasActionErrors()"> <div class="alert_msg alert"> <s:actionerror escape="false"/> </div> </s:if>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.