首页 > 其他 > 详细

java 从零开始,学习笔记之基础入门<Struts2_Spring_整合>(四十一)

时间:2014-02-19 22:23:06      阅读:420      评论:0      收藏:0      [点我收藏+]

Struts-Spring

Struts-Spring整合配置图

 bubuko.com,布布扣


Spring配置文件

applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>

<beans

    xmlns="http://www.springframework.org/schema/beans"

    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

    xmlns:p="http://www.springframework.org/schema/p"

    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

 

    <import resource="applicationContext-dao.xml"/>

 

    <import resource="applicationContext-service.xml"/>

   

    <import resource="applicationContext-action.xml"/>

 

</beans>

 

applicationContext-action.xml

<?xml version="1.0" encoding="UTF-8"?>

<beans

    xmlns="http://www.springframework.org/schema/beans"

    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

 

    <bean name="groupmaction" class="com.softeem.action.GroupManagerAction">

         <property name="service" ref="gservice">

         </property>

    </bean>

</beans>

 

applicationContext-service.xml

<?xml version="1.0" encoding="UTF-8"?>

<beans

    xmlns="http://www.springframework.org/schema/beans"

    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

 

    <bean name="gservice" class="com.softeem.service.impservice.GroupService">

         <property name="dao" ref="groopservice">

         </property>

    </bean>

</beans>

 

applicationContext-dao.xml

<?xml version="1.0" encoding="UTF-8"?>

<beans

    xmlns="http://www.springframework.org/schema/beans"

    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

    xmlns:p="http://www.springframework.org/schema/p"

    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

 

    <bean name="groopservice" init-method="init" destroy-method="destroy" class="com.softeem.dao.impdao.GroupDAO" scope="prototype">

       <property name="name" value="产品研发组">

       </property>

      

       <constructor-arg type="int" value="1000"></constructor-arg>

    </bean>

 

</beans>

 

Struts配置文件

Struts.xml

<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE struts PUBLIC

    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"

    "http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>

    <package name="group" extends="struts-default">

       <action name="groupadd" class="groupmaction">

           <result name="success">success.jsp</result>

       </action>

    </package>

</struts>

 

Struts.properties

struts.action.extension=do

 

struts.objectFactory=spring

 

struts.objectFactory.spring.autowire=name

 

整合需导入的插件包

 bubuko.com,布布扣

Web.xml配置文件

Web.xml

<?xml version="1.0" encoding="UTF-8"?>

<web-app version="2.5"

    xmlns="http://java.sun.com/xml/ns/javaee"

    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee

    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

  <welcome-file-list>

    <welcome-file>index.jsp</welcome-file>

  </welcome-file-list>

 

  <context-param>

    <param-name>contextConfigLocation</param-name>

    <param-value>classpath*:applicationContext-*.xml</param-value>

  </context-param>

 

  <listener>

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

  </listener>

 

  <filter>

    <filter-name>filterDispatcher</filter-name>

    <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>

  </filter>

 

  <filter-mapping>

    <filter-name>filterDispatcher</filter-name>

    <url-pattern>/*</url-pattern>

  </filter-mapping>

</web-app>

 

java 从零开始,学习笔记之基础入门<Struts2_Spring_整合>(四十一)

原文:http://blog.csdn.net/rulon147/article/details/19475487

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!