Struts2中Action的搜素顺序
来源:互联网 发布:软件健壮性 软件可靠性 编辑:程序博客网 时间:2024/06/05 06:27
当我们在struts.xml中配置action的时候,设置了package的namepace,但浏览器打开的路径与其不相同也能运行action。
比如:我们的创建一个struts2项目,项目名为:struts2。struts.xml配置如下:
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN" "http://struts.apache.org/dtds/struts-2.5.dtd"> <struts> <package name="default" namespace="/test" extends="struts-default"> <action name="helloworld" class="action.HelloWorldAction"> <result name="success">/result.jsp</result> </action> </package> </struts>
理论上,我们在浏览器中输入的地址为: http://localhost:8080/struts2/test/helloworld.action
才能运行helloworld.action。但是我们把地址改为 http://localhost:8080/struts2/aaaa/helloworld.action
也能访问。
Struts2中Action的搜素顺序:
当我们访问http://localhost:8080/strutsProject/path1/path2/path3/Test.action
的时候:
首先,判断package是否存在,如path1/path2/path3
- ①如果存在:判断Action是否存在,比如:Test.action。如果不存在则跳转到默认的namespace(在struts.xml中指定)中去找Action;如果不存在,则直接报错
- ② 如果不存在:依次检查上一级package是否存在(直到默认namespace),执行 ①。
虽然理论上我们只要正确输入Action就能运行,但推荐还是要正确输入package哦
阅读全文
1 0
- Struts2中Action的搜素顺序
- Struts2中Action的搜索顺序
- struts2中Action名称的搜索顺序
- struts2中Action名称的搜索顺序
- struts2中Action名称的搜索顺序
- struts2中Action名称的搜索顺序举例说明
- struts2中action搜索顺序解惑
- Struts2.0学习---Action名称的搜素顺序及配置的默认值
- struts2的action的访问顺序
- struts2 Action 名称的搜索顺序
- Struts2 Action名称的搜索顺序
- 详解Struts2 Action名称的搜索顺序
- 详解Struts2 Action名称的搜索顺序
- Struts2之Action名称的搜索顺序
- 【struts2】Action名称的搜索顺序
- struts2 Action名称的搜索顺序
- struts2 ---- namespace和action的查找顺序
- struts2之Action名称的搜索顺序
- C/C++-套接字一般流程
- 笔记:Unity3d
- 织梦DedeCMS从入门到精通建站视频教程全集
- JDBC问答题
- 产品设计中常见的错误有哪些?
- Struts2中Action的搜素顺序
- 计算机组成原理个人笔记(一)
- setObjectColor技巧
- iscsi的基本用法
- java语言基础-如何设计方法
- [转]ubuntu 服务器搭建 Shadowsocks 服务
- 缓冲区(Buffer)
- 获得Animator当前播放的AnimationClip
- 多边形重心问题 NYOJ 3 思路+代码