struts配置文件默认值及跳转Action的方法
2017-01-05 21:42
579 查看
一、Result:
Name属性默认值:”success”;
Type属性默认值:”dispatcher”
Redirect:重定向
redirectAction:重定向Action:指向另一个actionName。
二、还可以通过Action的属性存储下一个actionName,在result中通过表达式${属性名}动态获取目标Action。
1声明nextAuction,设置setter/getter方法
2在login()方法中指定nextAuction
3在result中加入
三、在跳转action时带上参数
Name属性默认值:”success”;
Type属性默认值:”dispatcher”
Redirect:重定向
<result name="input" type="redirect">index.jsp</result>
redirectAction:重定向Action:指向另一个actionName。
<result name="success" type="redirectAction">logoutUser</result>
二、还可以通过Action的属性存储下一个actionName,在result中通过表达式${属性名}动态获取目标Action。
1声明nextAuction,设置setter/getter方法
private String nextAuction; public String getNextAuction() { return nextAuction; } public void setNextAuction(String nextAuction) { this.nextAuction = nextAuction; }
2在login()方法中指定nextAuction
public String login() throws Exception { slist = new ArrayList<String>(); slist.add("刘备"); slist.add("孙权"); slist.add("曹操"); ulist=new ArrayList<User>(); ulist.add(new User("刘备",38)); ulist.add(new User("曹操",45)); ulist.add(new User("孙权",27)); msg = "welcome: " + userName; if (user.getUserName().equals("张三")) { Map<String, Object> session = ActionContext.getContext() .getSession(); System.out.println(user.getUserName()+" "+user.getAge()); session.put("currUser", user.getUserName()); nextAuction="logoutUse+r"; return "success"; } else { return "error"; } }
3在result中加入
<result name="success" type="redirectAction">${nextAuction}</result>
三、在跳转action时带上参数
在result中设置actionName和参数 <result name="success" type="redirectAction"> <param name="actionName">logoutUser</param> <param name="userName">${user.userName}</param> </result>
相关文章推荐
- SSH与SSM学习之Struts203——主配置文件配置_常量配置_动态方法配置_action书写方式
- 关于用struts所配置的Action默认页面的跳转问题
- Struts2第三篇【Action开发方式、通配符、Struts常量、跳转全局视图、action节点默认配置】
- 如何配置tomcat项目的默认页面为.action或其他后缀名的方法(文件)
- Struts2第三篇【Action开发方式、通配符、Struts常量、跳转全局视图、action节点默认配置】
- struts2之Action配置的各项默认值、Action跳转、result配置的各种试图类型及多个struts配置文件
- struts2 两个action方法的跳转 struts.xml怎么配置
- hibernate 映射文件配置默认值方法
- struts2之Action配置的各项默认值、result配置的各种试图转发类型及为应用指定多个struts配置文件
- 用struts (webwork) 的action配置文件和ant进行权限配置(我所在项目的权限解决方案)
- struts配置文件出现莫名错误解决方法
- struts2默认配置文件 struts-default.xml 研究
- 利用struts.properties文件配置Struts2默认属性
- struts中Action跳转jsp页面图片.css乱----解决方法
- struts资源文件的配置及程序调试的方法-视频(包含所有中文乱码的解决方案)
- struts2之Action配置的各项默认值、result配置的各种视图转发类型及为应用指定多个struts配置文件
- struts2之Action配置的各项默认值、result配置的各种试图转发类型及为应用指定多个struts配置文件
- 在Struts action中利用.do跳转到另一action传值方法
- Struts-config.xml配置文件《action-mappings》元素的详解
- struts ,action,跳转变化页面方法