标签: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