- src/main/resources/tfw/integration_demo/_04_spring_web_mvc/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:context="http://www.springframework.org/schema/context"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/jdbc
http://www.springframework.org/schema/jdbc/spring-jdbc-3.2.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-3.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa-1.3.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.2.xsd">
<import resource="sub_files/00_common.xml"/>
<import resource="sub_files/01_basic_submit.xml"/>
<import resource="sub_files/02_basic_jdbc_crud.xml"/>
</beans>
- src/main/resources/tfw/integration_demo/_04_spring_web_mvc/sub_files/00_common.xml
,包括数据源在内的公用对象配置文件:
<?xml version="1.0" encoding="UTF-8"?>
<beans ……>
<bean id="internalRealNameResourceView"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass"
value="tfw.integration_demo._04_spring_web_mvc.view.InternalRealNameResourceView"/>
<property name="order" value="999"/>
</bean>
<!-- [########################################] -->
<util:properties id="dsProps"
location="classpath:tfw/integration_demo/datasource.properties"/>
<bean id="ds" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="#{dsProps['ds_cfg.jdbc_driver']}"/>
<property name="url" value="#{dsProps['ds_cfg.jdbc_url']}"/>
<property name="username" value="#{dsProps['ds_cfg.jdbc_user']}"/>
<property name="password" value="#{dsProps['ds_cfg.jdbc_passwd']}"/>
</bean>
</beans>
- src/main/resources/tfw/integration_demo/_04_spring_web_mvc/sub_files/01_basic_submit.xml
,基本数据提交与跳转样例配置文件:
<?xml version="1.0" encoding="UTF-8"?>
<beans ……>
<bean id="basic.dsCfgCtrl"
class="tfw.integration_demo._04_spring_web_mvc._01_basic.controller._01_DataSourceConfigController"/>
<bean id="basic.urlMapping"
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="/tfw/integration_demo/04_spring_web_mvc/01_basic/01_ds_config/action.spr">basic.dsCfgCtrl</prop>
</props>
</property>
</bean>
</beans>
说明 / 注意事项:
- “<bean id="……" ……>……</bean>”:
“URI
映射”对象拆分为两个,各自指定
ID
以作区分。
- src/main/resources/tfw/integration_demo/_04_spring_web_mvc/sub_files/02_basic_jdbc_crud.xml
,基本 JDBC
增删改查样例配置文件:
<?xml version="1.0" encoding="UTF-8"?>
<beans ……>
<bean id="crud.basic_jdbc.urlMapping"
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="/tfw/integration_demo/04_spring_web_mvc/02_crud/01_basic_jdbc_crud/01_user_mgr/action.spr">crud.basic_jdbc.userMgrCtrl</prop>
<prop key="/tfw/integration_demo/04_spring_web_mvc/02_crud/01_basic_jdbc_crud/02_item_mgr/action.spr">crud.basic_jdbc.itemMgrCtrl</prop>
</props>
</property>
</bean>
<bean id="crud.basic_jdbc.userDAO"
class="tfw.integration_demo._04_spring_web_mvc._02_crud._01_basic_jdbc_crud.dao.impl.oracle.UserDAO">
<constructor-arg index="0" ref="ds"/>
</bean>
<bean id="crud.basic_jdbc.userMgrSvc"
class="tfw.integration_demo._04_spring_web_mvc._02_crud._01_basic_jdbc_crud.service._01_UserMgrService">
<property name="userDAO" ref="crud.basic_jdbc.userDAO"/>
</bean>
<bean id="crud.basic_jdbc.userMgrCtrl"
class="tfw.integration_demo._04_spring_web_mvc._02_crud._01_basic_jdbc_crud.controller._01_UserMgrController">
<property name="userMgrSvc" ref="crud.basic_jdbc.userMgrSvc"/>
</bean>
<!-- [########################################] -->
<bean id="crud.basic_jdbc.itemDAO"
class="tfw.integration_demo._04_spring_web_mvc._02_crud._01_basic_jdbc_crud.dao.impl.oracle.ItemDAO">
<constructor-arg index="0" ref="ds"/>
</bean>
<bean id="crud.basic_jdbc.itemMgrSvc"
class="tfw.integration_demo._04_spring_web_mvc._02_crud._01_basic_jdbc_crud.service._02_ItemMgrService">
<property name="itemDAO" ref="crud.basic_jdbc.itemDAO"/>
</bean>
<bean id="crud.basic_jdbc.itemMgrCtrl"
class="tfw.integration_demo._04_spring_web_mvc._02_crud._01_basic_jdbc_crud.controller._02_ItemMgrController">
<property name="itemMgrSvc" ref="crud.basic_jdbc.itemMgrSvc"/>
</bean>
</beans>
说明 / 注意事项:
- “<bean id="……" ……>……</bean>”:
“URI
映射”对象拆分为两个,各自指定
ID
以作区分。