一、result配置:                                    

struts2学习(4)struts2核心知识III

result - name 就是前面返回的值,success,error等。
type:
dispatcher. 默认是这个,底层是jsp的forward;
redirect:重定向;
chain:比如在aAction里面请求的东西,返回的时候到另一个Action里面继续执行,并且数据可以共享;相当于内部转发到了一个新的Action
redirectAction:重定向到一个Action;例子中从hello action中的数据,重定向到hello2,这里面的数据是带不过去的(name的值带不过去);
freemarker:一种模板技术;
velocity:也是一种模板;
 
 

1.result中的type类型:                        

com.cy.action.HelloAction.java:

package com.cy.action;

import com.opensymphony.xwork2.ActionSupport;

public class HelloAction extends ActionSupport{

    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    
    private String name;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String execute() throws Exception {
        return SUCCESS;
    }
    
    //redirect
    public String r() throws Exception {
        return "r";
    }
    
    //chain
    public String c() throws Exception {
        return "c";
    }
    
    //redirectAction
    public String ra() throws Exception {
        return "ra";
    }
    
}
View Code

相关文章:

  • 2022-12-23
  • 2021-08-01
  • 2021-10-24
  • 2021-05-30
  • 2021-06-28
  • 2021-12-01
猜你喜欢
  • 2021-10-02
  • 2021-11-06
  • 2021-10-24
  • 2021-09-11
  • 2021-09-21
  • 2021-08-18
相关资源
相似解决方案