Struts2入門–ActionSupportでRequest、Sessionを取得する

Javaコード:
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionSupport;

public class Logincft3Action extends ActionSupport{
private HttpServletRequest request;
private HttpSession session;
private ServletContext application;

@Override
public String execute() throws Exception {
// TODO Auto-generated method stub
this.request = ServletActionContext.getRequest();
this.session = this.request.getSession();
this.application = ServletActionContext.getServletContext();
this.request.setAttribute(“attribute", “request value servlet not IoC “);
this.session.setAttribute(“attribute", “session value servlet not IoC “);
this.application.setAttribute(“attribute", “application value servlet not IoC “);
return SUCCESS;
}

}

Java

Posted by arkgame