如何防止struts中的通配符命名空间? [英] How to prevent the wildcard namespace in struts?

查看:15
本文介绍了如何防止struts中的通配符命名空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个问题,我在以下情况下无法找到关键字:

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>

上面的网址应该是http://xyz.com/administrator和它工作正常.但是,如果我将网址更改为 http://xyz.com/asdasd/asdasdasd/administrator 它仍然有效,但我不能接受这个!因此,任何仅告诉 struts http://xyz.com/administrator 的设置都被接受?谢谢!

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!

推荐答案

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

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

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

这篇关于如何防止struts中的通配符命名空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆