struts2的命名空间分为两类:
1)默认命名空间
在struts2中的struts.xml中有package的namespace属性如果此属性为""或者不填写则标识默认命名空间
如:<package name="index" extends="struts-default">
请求路径先从制定命名空间开始匹配执行,如果匹配不到则从默认命名空间开始匹配执行。
2)制定命名空间
在struts2中的struts.xml中有package的namespace属性为"/"或者"/***"则标识制定命名空间
前者的URL访问是根目录访问,后者是根目录/namespace访问。
请求路径先从制定命名空间开始匹配执行,如果匹配到则执行否则执行默认命名空间。如果都执行不到则报告错误信息。
默认命名空间和命名空间的区别:
默认命名空间里的ACTION可以处理任何命名空间的ACTION请求。
根命名空间智能处理根命名空间下的ACTION请求。
命名空间只有一个级别。描述为:如果请求URL为:http://local.struts2.com:8080/test/namespace/login.action
struts2先从/test/namespace的命名空间中查找login的ACTION,如果找到该命名空间的ACTION则处理此action的请求。否则,struts2将直接进入默认的命名空间查找名为login的action,而不会在/test的命名空间下面查找login的ACTION
分享到:
相关推荐
前几天在网上下载一个struts2的helloword的例子,那个作者也真够缺德的,搞个错误的程序,害得我查了一天的程序错误。 最后发现竟然是struts.xml被写成啦sturts.xml。 碰见这样的问题先鄙视下提供例子的作者, 再...
namespace :对应与项目名称后面的"/"(例如Struts2_0100_Introduction后面的"/") (http://localhost:8080/Struts2_0100_Introduction/) 四、 标签 是用来解决重名的问题,例如当系统的前台和后台都有一个action...
struts2实现的学生信息管理系统 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" ...
Namespace、自定义Action、路径问题、通配符、包含模块配置文件、默认Action、接受用户输入、服务器跳转、Action中访问web元素、简单数据校验、调用Action的自定义方法 5struts2国际化 ......... 6 struts2输入校验...
<package name="demo" namespace="/mystruts" extends="struts-default"> <action name="sum" class="action.SumAction"> <result name="positive">/positive.jsp <result name="negative">/negative.jsp ...
01 Struts2-Action 5 一、 Struts作用: 5 二、 搭建Struts2的运行环境: 5 三、 Namespace 6 四、 标签 6 五、 Action 6 六、 路径问题的说明 8 七、 Action的动态调用方法 8 八、 Action通配符(wildcard)的配置 9 ...
namespace:定义package命名空间 该命名空间影响到url的地址,例如此命名空间为/test那么访问是的地址为http://localhost:8080/struts2/test/XX.action --> <package name="com.kay.struts2" extends="struts-...
从struts2.1版本开始,Convention Plugin作为替换替换Codebehind Plugin来实现Struts2的零配置。 • 包命名习惯来指定Action位置 • 命名习惯制定结果(支持JSP,FreeMarker等)路径 • 类名到URL的约定转换 • 包名...
01 Struts2-Action 5 一、 Struts作用: 5 二、 搭建Struts2的运行环境: 5 三、 Namespace 6 四、 标签 6 五、 Action 6 六、 路径问题的说明 8 七、 Action的动态调用方法 8 八、 Action通配符(wildcard)的配置 9 ...
<package name="default" namespace="/" extends="struts-default"> <action name="helloworld" class="com.mytest.HelloWorldAction"> <result> /result.jsp </action> ...
This result uses the ActionMapper provided by the ActionMapperFactory to redirect the browser to a URL that invokes the specified action and (optional) namespace. This is better than the ...
-- 添加如下内容 --> <result-types> <result-type name="streamx" class="com.sunspoter.lib.web.struts2.dispatcher.StreamResultX"/> </result-types> <action name="download" class="com.DownloadAction"> <...
4.建立文件夹需要在src/struts2.xml里添加一句话:<package name="folder1" namespace="/folder1" extends="default"> 5.WebRoot/WEB-INF/jsp目录建立对应的文件夹folder1 6.在包com.test.web.action添加类,比如...
struts2课件 很好的struts2当输入login.jsp访问jsp页面填写完相关信息并提交给login.action时,它会首先被在web.xml中配置的过滤器监听到,过滤器会去查找strust.xml文件,并结合namespace查找名为login的action,...
本书是广受赞誉的Struts 2优秀教程,它全面而深入地阐述了Struts 2的各个特性,并指导开发人员如何根据遇到的问题对症下药,选择使用最合适的特性。作者处处从实战出发,在丰富的示例中直观地探讨了许多实用的技术,...
• 包命名习惯来指定Action位置• 命名习惯制定结果(支持JSP,FreeMarker等)路径• 类名到URL的约定转换• 包名到命名空间(namespace)的约定转换• 遵循SEO规范的链接地址(即:使用my-action 来替代 ...
struts2.0扫盲文档2加入struts.xml配置文件(自己建) <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> ...
Struts2练习小程序源代码,包括action,namespace等内容,虽说是练习程序,但有助于提高
http://localhost:8080/ struts2会拦截,出现异常信息 There is no Action mapped for namespace / and action name.默认配置的welcomefile没有起作用。 按附件配置即可解决此问题