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"时,必须以如下方式访问:
引用
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"时,必须以如下方式访问:
引用