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
时间: 2024-12-13 22:08:04