struts2中的namespace说明
namespace决定了action的访问路径,默认为"",可以接收所有路径的action。
namespace可以写为/,或者/xxx,或者/xxx/yyy,对应的action访问路径为:/index.action、/xxx/index.action、/xxx/yyy/index.action。
(说明:namespace最好也用模块来命名)
如下配置所示,应用访问路径为:
http://localhost:8080/struts2_0200_Namespace/front/hello.action
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<!-- Add packages here -->
<constant name="struts.devMode" value="true" />
<package name="front" namespace="/front" extends="struts-default">
<action name="hello">
<result>
/namespace.jsp
</result>
</action>
</package>
</struts>