读书人

struts2学习札记namespace

发布时间: 2012-09-15 19:09:28 作者: rapoo

struts2学习笔记——namespace
struts2学习笔记——namespace

namespace决定了action的访问路径,默认为"",可以接收所有路径的action<br />
namespace可以写为/,或者/xxx,或者/xxx/yyy,对应的action访问路径为/index.action,
/xxx/index.action,或者/xxx/yyy/index.action.<br/>
namespace最好也用模块来进行命名

首先看下struts2的配置文件:
Java代码
<package name="default" namespace="/" extends="struts-default">
<action name="hello">
<result>
/Hello.jsp
</result>
</action>
</package>

<package name="default" namespace="/" extends="struts-default">
<action name="hello">
<result>
/Hello.jsp
</result>
</action>
</package>


namespace 默认是namespace=””.

当namespace=”” 或者" namespace="/"时:客户端访问的时候:

引用
http://localhost:8888/工程名/*/*/hello 等都可以进行访问。


当namespace="/hello"时,必须以如下方式访问:

引用

读书人网 >编程

热点推荐