Struts2 与普通的java内通信 也就是所谓的 Action类 来获取servlet中request对象和response对象

2021-01-05 04:28

阅读:637

标签:str   info   image   java   src   http   void   bsp   Servle   

 

方法1:

implements ServletRequestAware, ServletResponseAware

public class Hello implements ServletRequestAware, ServletResponseAware {

    private HttpServletRequest request;
    private HttpServletResponse response;


    @Override
    public void setServletRequest(HttpServletRequest httpServletRequest) {
        this.request = httpServletRequest;
    }

    @Override
    public void setServletResponse(HttpServletResponse httpServletResponse) {
        this.response = httpServletResponse;
    }
}

 

方法2

在普通java类中通过ServletActioContext对象来获取

技术图片

 

Struts2 与普通的java内通信 也就是所谓的 Action类 来获取servlet中request对象和response对象

标签:str   info   image   java   src   http   void   bsp   Servle   

原文地址:https://www.cnblogs.com/gaoSJ/p/12981387.html


评论


亲,登录后才可以留言!