`
zds420
  • 浏览: 198468 次
  • 性别: Icon_minigender_1
  • 来自: 合肥
社区版块
存档分类
最新评论

Struts2 之ACTION的namespace

 
阅读更多

 

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的例子:彻底解决STRUTS2 错误There is no Action mapped for namespace / and action name login

    前几天在网上下载一个struts2的helloword的例子,那个作者也真够缺德的,搞个错误的程序,害得我查了一天的程序错误。 最后发现竟然是struts.xml被写成啦sturts.xml。 碰见这样的问题先鄙视下提供例子的作者, 再...

    struts2 学习笔记 实战

    namespace :对应与项目名称后面的"/"(例如Struts2_0100_Introduction后面的"/") (http://localhost:8080/Struts2_0100_Introduction/) 四、 标签 是用来解决重名的问题,例如当系统的前台和后台都有一个action...

    struts2实例 学生信息管理系统

    struts2实现的学生信息管理系统 &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" ...

    Struts2全解Struts2全解

    Namespace、自定义Action、路径问题、通配符、包含模块配置文件、默认Action、接受用户输入、服务器跳转、Action中访问web元素、简单数据校验、调用Action的自定义方法 5struts2国际化 ......... 6 struts2输入校验...

    struts2示例程序

    &lt;package name="demo" namespace="/mystruts" extends="struts-default"&gt; &lt;action name="sum" class="action.SumAction"&gt; &lt;result name="positive"&gt;/positive.jsp &lt;result name="negative"&gt;/negative.jsp ...

    Struts2 学习笔记

    01 Struts2-Action 5 一、 Struts作用: 5 二、 搭建Struts2的运行环境: 5 三、 Namespace 6 四、 标签 6 五、 Action 6 六、 路径问题的说明 8 七、 Action的动态调用方法 8 八、 Action通配符(wildcard)的配置 9 ...

    jfreechar 整合struts2.1.8版本生成线图,饼图,柱形图

    namespace:定义package命名空间 该命名空间影响到url的地址,例如此命名空间为/test那么访问是的地址为http://localhost:8080/struts2/test/XX.action --&gt; &lt;package name="com.kay.struts2" extends="struts-...

    Struts2 Convention Plugin中文文档 Annotion

    从struts2.1版本开始,Convention Plugin作为替换替换Codebehind Plugin来实现Struts2的零配置。 • 包命名习惯来指定Action位置 • 命名习惯制定结果(支持JSP,FreeMarker等)路径 • 类名到URL的约定转换 • 包名...

    Struts2帮助```````

    01 Struts2-Action 5 一、 Struts作用: 5 二、 搭建Struts2的运行环境: 5 三、 Namespace 6 四、 标签 6 五、 Action 6 六、 路径问题的说明 8 七、 Action的动态调用方法 8 八、 Action通配符(wildcard)的配置 9 ...

    struts2配置2.5版

    &lt;package name="default" namespace="/" extends="struts-default"&gt; &lt;action name="helloworld" class="com.mytest.HelloWorldAction"&gt; &lt;result&gt; /result.jsp &lt;/action&gt; ...

    Struts2 2.3.16_doc

    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 ...

    解决struts2下载异常的jar包 struts2-sunspoter-stream-1.0.jar

    -- 添加如下内容 --&gt; &lt;result-types&gt; &lt;result-type name="streamx" class="com.sunspoter.lib.web.struts2.dispatcher.StreamResultX"/&gt; &lt;/result-types&gt; &lt;action name="download" class="com.DownloadAction"&gt; &lt;...

    搭建好的一个struts2环境

    4.建立文件夹需要在src/struts2.xml里添加一句话:&lt;package name="folder1" namespace="/folder1" extends="default"&gt; 5.WebRoot/WEB-INF/jsp目录建立对应的文件夹folder1 6.在包com.test.web.action添加类,比如...

    struts2课件

    struts2课件 很好的struts2当输入login.jsp访问jsp页面填写完相关信息并提交给login.action时,它会首先被在web.xml中配置的过滤器监听到,过滤器会去查找strust.xml文件,并结合namespace查找名为login的action,...

    深入浅出Struts2(附源码)

    本书是广受赞誉的Struts 2优秀教程,它全面而深入地阐述了Struts 2的各个特性,并指导开发人员如何根据遇到的问题对症下药,选择使用最合适的特性。作者处处从实战出发,在丰富的示例中直观地探讨了许多实用的技术,...

    struts2注解详细说明

    • 包命名习惯来指定Action位置• 命名习惯制定结果(支持JSP,FreeMarker等)路径• 类名到URL的约定转换• 包名到命名空间(namespace)的约定转换• 遵循SEO规范的链接地址(即:使用my-action 来替代 ...

    struts2.0扫盲文档

    struts2.0扫盲文档2加入struts.xml配置文件(自己建) &lt;!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"&gt; ...

    Struts2小程序源代码

    Struts2练习小程序源代码,包括action,namespace等内容,虽说是练习程序,但有助于提高

    解决使用struts2 时 访问web工程首页问题

    http://localhost:8080/ struts2会拦截,出现异常信息 There is no Action mapped for namespace / and action name.默认配置的welcomefile没有起作用。 按附件配置即可解决此问题

Global site tag (gtag.js) - Google Analytics