struts2 中namespace的问题

编号0421 2014-06-11 09:16:27
struts.xml配置如下:
<struts>
<constant name="struts.devMode" value="true" />
<package name="default" namespace="/a" extends="struts-default">
<global-results>
<result name="error">/error.jsp</result>
</global-results>
<global-exception-mappings>
<exception-mapping exception="java.lang.Exception" result="error"/>
</global-exception-mappings>
<action name="hello" class="com.gmh.test.Test">
<result>
/Hello.jsp
</result>
</action>

</package>
</struts>
问题是:我在浏览器中输入/a/hello能访问到Hello.jsp
输入/a/xx/xxx/xxxx/hello也能访问到Hello.jsp
请问这是为什么?
...全文
95 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
编号0421 2014-06-12
  • 打赏
  • 举报
回复
谢谢楼上的!!
alexaxin 2014-06-12
  • 打赏
  • 举报
回复
引用 楼主 gmh0421 的回复:
struts.xml配置如下: <struts> <constant name="struts.devMode" value="true" /> <package name="default" namespace="/a" extends="struts-default"> <global-results> <result name="error">/error.jsp</result> </global-results> <global-exception-mappings> <exception-mapping exception="java.lang.Exception" result="error"/> </global-exception-mappings> <action name="hello" class="com.gmh.test.Test"> <result> /Hello.jsp </result> </action> </package> </struts> 问题是:我在浏览器中输入/a/hello能访问到Hello.jsp 输入/a/xx/xxx/xxxx/hello也能访问到Hello.jsp 请问这是为什么?
假如你在配置文件添加这样的配置 <constant name="struts.mapper.alwaysSelectFullNamespace" value="true"/> 后你就只能/a/hello访问了
Magical茏 2014-06-11
  • 打赏
  • 举报
回复


struts有这种机制
深蓝的独角仙 2014-06-11
  • 打赏
  • 举报
回复
这与action的搜索顺序有关,你可以百度一下,不管中间路径是什么,只要路径两边是存在的就能访问!

67,538

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧