Chinedu
Chinedu

Reputation: 103

Pass parameter to Struts2 Action to display view interchangeably

this is what I want to achieve I have three view i.e JSPs.Event.jsp,EventCancel.jsp and EventAdd.jsp. I want only One action to display each of these jsps. So example if the Action name is EventAction then one passes a parameter such as EventAction.action?eventviewname=Event , the EventAction should then show Event.jsp and so on. Now how do I configure my struts.xml to achieve this. Thank you

Like so true /view/inetreports/${reportName}.jsp false

Upvotes: 0

Views: 1235

Answers (1)

Software Prophets
Software Prophets

Reputation: 2976

I think I see what you're after. You can do this:

<action name="foo-*" class="your.package.EventAction" method="display" >
   <result name="success">{1}.jsp</result>
</action>

Then you call http://server/context/foo-Event and the jsp that gets called is Event.jsp. If you call http://server/context/foo-EventCancel you get EventCancel.jsp.

Is that what you wanted to do?

Upvotes: 1

Related Questions