I'm currently playing around with my Struts2 config for wildcard testing and I'm stuck with this one.
<action name="/*/*" class="checkBlogUrl" method="testing">
<param name="blogSiteUrl">{1}</param>
<param name="test">{2}</param>
<result name="success">/WEB-INF/jsp/cmsPages/index.jsp</result>
</action>
<action name="/*/postPreview1" class="blogPostAction" method="test">
<param name="blogSiteUrl">{1}</param>
<result name="success">/WEB-INF/jsp/cmsPages/templatePicker.jsp</result>
</action>
If I access myurl.com/hello/hi
I will be redirected to index.jsp
But if I access myurl.com/hello/postPreview1
I will also be redirected to index.jsp
instead of templatePicker.jsp
.
Am I doing something wrong here? The struts wildcard doc said that the last one will win
EDIT: Just tried to switch them around and it worked O_O. Am I misreading the doc?
You are using slashes in action name, that incorrectly works with wildcard mapper. As I said in the linked answer, the best pattern matcher in this case is the
regex
pattern matcher.See Advanced Wildcards.
About docs for wildcard mapper. Lets look at the example blank application:
So URLs will be matched in the order:
http://localhost:8080/example/HelloWorld
http://localhost:8080/example/Login_input
http://localhost:8080/example/Register
I would say that more specific mapping goes before less specific/common mapping and it wins because it's found first in the order of action configs. Everything that doesn't match the ordered configs fall into last mapping which is less specific.