DAO w/ Struts2
// ActionContextの取得
ActionContext context = ActionContext.getContext();
Map map = context.getContextMap();
// サーブレットコンテキストの取得
ServletContext application =
(ServletContext) map.getStrutsStatics.SERVLET_CONTEXT);
// WEBアプリケーションコンテキストの取得
WebApplicationContext applicationContext =
(WebApplicationContext) application.getAttribute
(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
// DAOの取得
DAO dao = (DAO) applicationContext.getBean("DAO");
// カテゴリ検索を実行
List result = dao.getList("getCategoryList", null);
ref:
http://www.h3.dion.ne.jp/~alpha-pz/misc2217.html
ActionContext context = ActionContext.getContext();
Map map = context.getContextMap();
// サーブレットコンテキストの取得
ServletContext application =
(ServletContext) map.getStrutsStatics.SERVLET_CONTEXT);
// WEBアプリケーションコンテキストの取得
WebApplicationContext applicationContext =
(WebApplicationContext) application.getAttribute
(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
// DAOの取得
DAO dao = (DAO) applicationContext.getBean("DAO");
// カテゴリ検索を実行
List result = dao.getList("getCategoryList", null);
ref:
http://www.h3.dion.ne.jp/~alpha-pz/misc2217.html
