欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

struts+spring+hibernate三個框架的整合

 更新時間:2017年09月18日 10:54:02   投稿:mrr  
這篇文章主要介紹了struts+spring+hibernate三個框架的整合,需要的朋友可以參考下

準(zhǔn)備三個框架結(jié)合的lib包

Spring3結(jié)合Struts2的步驟如下:

1:開啟Struts2結(jié)合Spring3,在struts.xml中添加如下語句:

java代碼:

<constant name="struts.objectFactory" value="spring"/> 

2:在web.xml中添加listener,如下:

java代碼:

<listener> 
    <listener-class> 
org.springframework.web.context.ContextLoaderListener</listener-class> 
  </listener> 

3:在web.xml中指定需要初始讀取的spring配置文件,如下:

java代碼:

<context-param> 
  <param-name>contextConfigLocation</param-name> 
  <param-value>/WEB-INF/applicationContext-*.xml,classpath*:applicationContext-*.xml</param-value> 
</context-param> 

5.當(dāng)然別忘了加上Struts2自己的filter  

4:在struts.xml中Action配置的時候,如下:

java代碼:

<action name="testAction" class="springBeanName"> 
  <result name="success">/index.jsp</result> 
</action>

5:在Spring中正常定義Bean就可以了,把Action定義成為Bean,如下:

java代碼:

<bean id="testAction" class="com.bjpowernode.test.web.TestActioin"> 
<property name="ebi" ref="testEbi"/> 
</bean> 

6:在Struts的Action中,就可以通過依賴注入的方式來注入需要使用的接口了。

總結(jié)

以上所述是小編給大家介紹的struts+spring+hibernate三個框架的整合,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評論