Action的搜索顺序(Struts2搜索Action的机制)
当访问如下链接时,
http://localhost:8080/struts2Demo/path1/path2/path3/LoginAction.action
第一步:判断当前路径下action是否存在,如:path1/path2/path3/
第二步:存在:则去访问相应的Action;不存在:检查上一级路径的package中是否存在action(直到默认的namespace,此处默认的namespace为"/"),重复第一步。
第三步:如果没有则报错。
<form action ="LoginAction.action" method ="post" >
<input type= "submit" value ="测试" />
</form>
struts.xml
<package name ="default" namespace ="/" extends ="struts-default" >
<action name= "LoginAction" class="com.struts2.action.LoginAction" method ="execute" >
<result name= "success">/success.jsp </result>
</action>
</package>
LoginAction.java
public class LoginAction extends ActionSupport{
public String execute (){
String result="success" ;
return result ;
}
}
**************************************************************************************************
如若转载请注明出处,谢谢。By奋斗的小蘑菇
Action的搜索顺序(Struts2搜索Action的机制)的更多相关文章
- struts2 笔记01 登录、常用配置参数、Action访问Servlet API 和设置Action中对象的值、命名空间和乱码处理、Action中包含多个方法如何调用
Struts2登录 1. 需要注意:Struts2需要运行在JRE1.5及以上版本 2. 在web.xml配置文件中,配置StrutsPrepareAndExecuteFilter或FilterDis ...
- Struts2 语法--action
xml的注释: <!--叨叨叨叨--> web.xml注释格式": <?xml version="1.0" encoding="UTF-8&q ...
- Python 模块化 模块搜索顺序、重复导入、模块加载列表(五)
模块搜索顺序.重复导入.模块加载列表 0x00 模块搜索顺序: 举例: #test.py import sys for p in sys.path: print(p) 运行结果: C:\python ...
- struts2的action是线程安全的,struts1的action不是线程安全的真正原因
为什么struts2的action是线程安全的,struts1的action不是线程安全的? 先对struts1和struts2的原理做一个简单的讲解 对于struts1 ,当第一次**.do的请求过 ...
- 笔记01 登录、常用配置参数、Action访问Servlet API 和设置Action中对象的值、命名空间和乱码处理、Action中包含多个方法如何调用
Struts2登录 1. 需要注意:Struts2需要运行在JRE1.5及以上版本 2. 在web.xml配置文件中,配置StrutsPrepareAndExecuteFilter或FilterDis ...
- 【Struts2学习笔记(1)】Struts2中Action名称的搜索顺序和多个Action共享一个视图--全局result配置
一.Action名称的搜索顺序 1.获得请求路径的URI,比如url是:http://server/struts2/path1/path2/path3/test.action 2.首先寻找namesp ...
- 第二篇——Struts2的Action搜索顺序
Struts2的Action的搜索顺序: 地址:http://localhost:8080/path1/path2/student.action 1.判断package是否存在,例如:/pat ...
- Struts2学习三----------Action搜索顺序
© 版权声明:本文为博主原创文章,转载请注明出处 Struts2的Action的搜索顺序 http://localhost:8080/path1/path2/student.action 1)判断pa ...
- 02. struts2中Action名称的搜索顺序
搜索顺序 获得请求路径的URI,例如URL为:http://localhost:8080/struts2/path1/path2/path3/student.action 首先寻找namespace为 ...
- Struts2的Action名称搜索顺序:2014.12.30
struts.xml配置: <struts> <package name="hw" namespace="/test" extends=&qu ...
随机推荐
- python成长之路【第十一篇】:网络编程之线程threading模块
一.threading模块介绍 threading 模块建立在 _thread 模块之上.thread 模块以低级.原始的方式来处理和控制线程,而 threading 模块通过对 thread 进行二 ...
- 使用phpmailer发送smtp邮件时提示 SMTP Error: Could not authenticate 错误
使用phpmailer发送smtp邮件时提示 SMTP Error: Could not authenticate 错误 这个错误是验证出现错误, $mail->Port = 25; //SMT ...
- android 实现类似qq未读消息点击循环显示
public void jumpUnread(boolean cycle) { List<ContactLogModel> dataList = adapter.getContactLog ...
- red hat安装mysql二进制包
数据包命名格式解释 mysql-5.7.15-linux-glibc2.5-x86_64.tar.gz 黑色粗体表示为包名称 蓝色表示linux系统二进制包 红色表示构架 1.上传mysql- ...
- adb shell使用
adb shell可以用来操纵数据库 1.在cmd界面 输入adb shell 进入adb shell 2.使用cd 切换到工作目录:使用ls查看文件 3.使用sqlite3+数据库名字 打开某个数据 ...
- git hub
如果希望保留生产服务器上所做的改动,仅仅并入新配置项, 处理方法如下:git stashgit pullgit stash pop然后可以使用git diff -w +文件名 来确认代码自动合并的情况 ...
- 使用JDBC获取Oracle连接时报错
The Network Adapter could not establish the connection 网络适配器不能创建连接 作为初学者的来说,这个问题让我找了好多次,每次重新开启 ...
- <js>实现回车键登陆方法,并处理谷歌与火狐不兼容的问题
1.在body中添加onkeydown事件 <body onkeydown="keyLogin(event);">2.使用js相应登陆添加方法//添加回车登陆事件 fu ...
- mac命令学习记录
1. 查找程序运行路径: which xxxx 2. 查找文件安装路径: whereis xxxx; 3. 编辑配置文件:vi ./.xxx : 进入需要编辑的文件: i 进行编辑 :输入:wq ...
- 计时器js
<html> <head> <meta http-equiv="Content-Type" content="text/html ...