Programming/Spring Framework
Struts 2. Action 객체에서 request, response 객체 사용하기
otamot
2009. 10. 28. 15:25
Action 객체 내에서 request 및 response 객체를 얻어오는 방법이다.
public class UserAction extends ActionSupport {
...
public String execute() {
HttpServletRequest request = ServletActionContext.getRequest();
HttpServletResponse response = ServletActionContext.getResponse();
...
return SUCCESS;
}
}
일단 Action 객체는 ActionSupport 클래스를 상속한다. 그리고 객체 내에서 ServletActionContext 객체를 통해서 request와 response 객체를 얻어올 수 있다.