I was following a tutorial on Struts2 upon looking at its config file I saw this
<package name="events" namespace="/events" extends="struts-default">
<action name="*" class="actions.events.{1}">
<result>/views/events/{1}.jsp</result>
<result name="redirect" type="redirect">${redirectUrl}</result>
</action>
</package>
Everything here is no rocket science, but what boggles my mind is this class="actions.events.{1}
what does the {1}
mean or do? what it is purpose?
The above is a wildcard mapping. {1} is a placeholder that will be replaced with the matched action name. So, if you have two actions Action1 and Action2, the above is similar to
<action name="Action1" class="actions.events.Action1">
<result>/views/events/Action1.jsp</result>
<result name="redirect" type="redirect">${redirectUrl}</result>
</action>
<action name="Action2" class="actions.events.Action2">
<result>/views/events/Action2.jsp</result>
<result name="redirect" type="redirect">${redirectUrl}</result>
</action>
More info in the documentation .
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.