自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Struts Action服務(wù)定位器

開發(fā) 后端
這里介紹Struts Action服務(wù)定位器,一個簡單的處理方法是使用一個服務(wù)定位器模式的類從一個Spring上下文中返回資源。

本文向大家介紹怎樣配置一個服務(wù)定位器的例子,可能好多人還不了解Struts Action服務(wù)定位器,沒有關(guān)系,看完本文你肯定有不少收獲,希望本文能教會你更多東西。

Struts Action提供一個服務(wù)定位器

既然我們已經(jīng)把我們的服務(wù)和我們的DAO連起來了,我們需要把我們的服務(wù)暴露給其它層。通常是一個像使用Struts或Swing這樣的用戶接口層里的代碼來使用這個服務(wù)。一個簡單的處理方法是使用一個服務(wù)定位器模式的類從一個Spring上下文中返回資源。這也可以靠引用bean ID通過Spring來直接完成。

這兒是一個在Struts Action中怎樣配置一個服務(wù)定位器的例子:

 

  1. public abstract class BaseAction extends Action {   
  2.  
  3. private IOrderService orderService;   
  4.  
  5. public void setServlet(ActionServlet actionServlet) {   
  6. super.setServlet(actionServlet);   
  7. ServletContext servletContext = actionServlet.getServletContext();   
  8.  
  9. WebApplicationContext wac = WebApplicationContextUtils.
    getRequiredWebApplicationContext( servletContext);   
  10.  
  11. this.orderService = (IOrderService)   
  12. wac.getBean("orderService");   
  13. }  
  14.  
  15. protected IOrderService getOrderService() {   
  16. return orderService;   
  17. }  

【編輯推薦】

  1. 詳細(xì)概述Hibernate Struts區(qū)別
  2. Struts 2:一流的AJAX支持
  3. 學(xué)習(xí)比較Struts2和Struts1:Struts2完勝
  4. 如何解決Struts Hibernate的整合問題
  5. 淺析Hibernate Struts分頁
責(zé)任編輯:佚名 來源: IT168
相關(guān)推薦

2009-09-29 11:03:07

SaveNewOrdeStruts框架

2022-11-03 08:00:00

Xpath動態(tài)元素定位器

2012-01-04 00:11:54

ibmdw

2016-06-08 11:52:47

互聯(lián)網(wǎng)智能

2011-08-11 13:02:43

Struts2Junit

2009-06-25 15:46:19

HttpServletStruts2教程Action類

2023-01-09 08:09:07

Spring項目模式

2017-09-10 17:00:42

服務(wù)器數(shù)據(jù)包丟棄

2009-02-01 10:05:00

2010-02-06 15:28:12

ibmdwStrutsREST

2018-09-20 08:35:13

機(jī)器學(xué)習(xí)云服務(wù)器故障

2009-09-22 13:02:05

ibmdwStruts

2009-06-18 11:37:24

Struts2中ForJavaScript

2009-07-20 16:51:59

Struts2.0+i

2010-12-28 16:55:04

惠普MicroServer服務(wù)器

2014-07-17 14:51:52

2021-04-05 17:55:16

GitHub惡意軟件加密貨幣

2009-04-15 09:05:31

2009-07-14 00:15:52

Webwork Act

2010-11-16 10:46:05

惠普處理器服務(wù)器
點贊
收藏

51CTO技術(shù)棧公眾號