spring管理struts、hibernate

一、spring管理struts配置

1、增加插件,修改

  struts-config.xml

    <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
    <set-property property="contextConfigLocation" value="/WEB-INF/classes/applicationContext.xml" />
  </plug-in>

2、在web.xml中配置spring

   增加插件管理

   <context-param>
   <param-name>contextConfigLocation</param-name>
   <param-value>
     /WEB-INF/classes/applicationContext.xml
   </param-value>
</context-param>

 增加監聽器

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

 

3、將DAO交由spring管理,之後通過IOC方式注入DAO對象

  在applicationContext.xml添加如下

   <bean name='/person' class="org.ssh.struts.PersonAction">
    <property name="persondao">
       <ref bean="persondao"/>
    </property>
  </bean>

struts-config.xml

<action-mappings >
    <action
      attribute="personForm"
      input="/form/person.jsp"
      name="personForm"
      parameter="status"
      path="/person"
      scope="request"
      type="org.ssh.struts.PersonAction" />
  
  </action-mappings>

 

 

   

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章