How to prevent the wildcard namespace in struts?

有些话、适合烂在心里 提交于 2019-11-28 04:55:20

问题


I am facing a problem that I couldn't find a key word for googleing the following situation:

<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>

The above url should be http://xyz.com/administrator and it works fine. However, if I change the url to http://xyz.com/asdasd/asdasdasd/administrator and it still works, but I can't accept this! So any setting to tell struts only http://xyz.com/administrator is accepted? Thanks!


回答1:


Set the alwaysSelectFullNamespace property to true.

From struts-default.properties:

### Whether to always select the namespace to be everything before the last slash or not
struts.mapper.alwaysSelectFullNamespace=true

XML configuration is preferred, so in your struts.xml:

<struts>
  <constant name="struts.mapper.alwaysSelectFullNamespace" value="true" />
  ...


来源:https://stackoverflow.com/questions/17690956/how-to-prevent-the-wildcard-namespace-in-struts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!