Hey i am new to struts2 or even to Struts so, i was looking the ways by which we can pass messages from action class to jsp page
Thanks
Yes, you can pass messages to jsp in struts2.You can use a code like this addActionMessage("You are valid user!");
in the action class. I think you need to extend ActionSupport for this. http://www.mkyong.com/struts2/struts-2-actionerror-actionmessage-example/
In your action
addActionMessage("Welcome")
addErrorMessage("Not Logged in")
in your jsp:
<s:actionmessage/>
<s:actionerror/>
In your action class, you will be calling addActionMessage()
for success message and addActionError()
for the failure message.
To display the error on the JSPs you will use <s:actionmessage />
and <s:actionerror />
.
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.