您在操作名称中使用斜杠,该斜杠在通配符映射器中无法正常使用。正如我在链接的答案中所说的,这种情况下最好的模式匹配器是
regex模式匹配器。
<constant name="struts.patternMatcher" value="regex"/>
请参阅高级通配符。
<action name="/{blogSiteUrl}/{test}" method="testing"> <result name="success">/WEB-INF/jsp/cmsPages/index.jsp</result></action><action name="/{blogSiteUrl}/postPreview1" method="test"> <result name="success">/WEB-INF/jsp/cmsPages/templatePicker.jsp</result></action>关于通配符映射器的文档。让我们看一下示例 空白 应用程序:
<package name="example" namespace="/example" extends="default"> <action name="HelloWorld" > <result>/WEB-INF/jsp/example/HelloWorld.jsp</result> </action> <action name="Login_*" method="{1}" > <result name="input">/WEB-INF/jsp/example/Login.jsp</result> <result type="redirectAction">Menu</result> </action> <action name="*" > <result>/WEB-INF/jsp/example/{1}.jsp</result> </action> <!-- Add actions here --></package>因此,URL将按以下顺序进行匹配:
http://localhost:8080/example/HelloWorld
http://localhost:8080/example/Login_input
http://localhost:8080/example/Register
我要说的是,更具体的映射先于较不具体/常见的映射,它之所以会获胜,是因为它是按操作配置的顺序首先找到的。所有与有序配置不匹配的内容都将落入最后一个不太具体的映射。



