アウトプットができる技術者に

it's a time to take a new step !

Struts2 HttpServlretReuqest / ServletContext の取得

ServletActionContextから取得できる。
Actionクラスでは RequestAware インタフェースを実装するのが普通。

HttpServletRequest request = ServletActionContext.getRequest();
System.out.println((String)request.getParameter("id")); // post/getパラメターの出力

ServletContext con = ServletActionContext.getServletContext();
con.getServletContext().getRealPath("."); // 物理パスの取得