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

查看:102
本文介绍了如何防止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 ,它工作正常.但是,如果我将URL更改为 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天全站免登陆