我遇到了一个问题,在以下情况下无法找到关键字来进行谷歌搜索:
<package name="Main" namespace="/" extends="struts-default">
<action name="administrator" class="com.xyz.AdminAction">
<result name="success">/WEB-INF/jsp/admin.jsp</result>
</action>
</package>
以上网址应为http://xyz.com/administrator 并且效果很好。但是,如果我将 url 更改为 http://xyz.com/asdasd/asdasdasd/administrator 它仍然有效,但我不能接受这一点!所以任何设置只告诉struts http://xyz.com/administrator 被接受吗?谢谢!
最佳答案
将 alwaysSelectFullNamespace
属性设置为 true
。
来自struts-default.properties
:
### Whether to always select the namespace to be everything before the last slash or not
struts.mapper.alwaysSelectFullNamespace=true
首选 XML 配置,因此在 struts.xml
中:
<struts>
<constant name="struts.mapper.alwaysSelectFullNamespace" value="true" />
...
关于struts2 - 如何防止struts中出现通配符命名空间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26235071/