新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
StrutsAction服務(wù)定位器
本文向大家介紹怎樣配置一個(gè)服務(wù)定位器的例子,可能好多人還不了解Struts Action服務(wù)定位器,沒有關(guān)系,看完本文你肯定有不少收獲,希望本文能教會(huì)你更多東西。

Struts Action提供一個(gè)服務(wù)定位器
既然我們已經(jīng)把我們的服務(wù)和我們的DAO連起來了,我們需要把我們的服務(wù)暴露給其它層。通常是一個(gè)像使用Struts或Swing這樣的用戶接口層里的代碼來使用這個(gè)服務(wù)。一個(gè)簡單的處理方法是使用一個(gè)服務(wù)定位器模式的類從一個(gè)Spring上下文中返回資源。這也可以靠引用bean ID通過Spring來直接完成。
這兒是一個(gè)在Struts Action中怎樣配置一個(gè)服務(wù)定位器的例子:
- public abstract class BaseAction extends Action {
- private IOrderService orderService;
- public void setServlet(ActionServlet actionServlet) {
- super.setServlet(actionServlet);
- ServletContext servletContext = actionServlet.getServletContext();
- WebApplicationContext wac = WebApplicationContextUtils.
getRequiredWebApplicationContext( servletContext);- this.orderService = (IOrderService)
- wac.getBean("orderService");
- }
- protected IOrderService getOrderService() {
- return orderService;
- }
- }
當(dāng)前標(biāo)題:StrutsAction服務(wù)定位器
當(dāng)前地址:http://m.5511xx.com/article/djpophh.html


咨詢
建站咨詢
