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>
本文详细介绍了Struts2框架中namespace的概念及其作用。通过具体的配置示例,解释了如何使用namespace来组织Action,并展示了不同形式的namespace对于Action访问路径的影响。
863

被折叠的 条评论
为什么被折叠?



