Struts2-学习笔记系列(3)-返回视图

Action执行execute返回字符串,又如何返回对应的页面呢?

关在在于struts中action节点配置的result。如下:

 

内置有的ERROR  SUCCESS等好几种。看源码即可

 

 1 public String execute() throws Exception {
 2 
 3     setTip("测试action包装变量");
 4 
 5     if (getUser().equals("zcx")) {
 6 
 7         ActionContext.getContext().getSession().put("user", getUser());
 8 
 9         return "success";
10 
11     }
12 
13     return "error";
14 
15 }
16  
17 
18 <action name="login">
19 
20     <result name="success">/WEB-INF/content/welcome.jsp</result>
21 
22 </action>
23  

 

posted @ 2016-06-04 22:18  逆风飞行  阅读(285)  评论(0编辑  收藏  举报