ssh框架中.xml文件小技巧分离xml

struts.xml文件

struts.xml文件里的action可以分离出来,如:

<!-- 预警信息监测 -->
<include file="config/struts/warningInformAtion-struts.xml"></include>

注: include是放在</struts>标签的前面

在src下面新建 package 名为:config.struts,再新建xml文件为warningInformAtion-struts.xml,这样,我们就可以把预警信息监测的action全放在warningInformAtion-struts.xml里面了

warningInformAtion-struts.xml的内容如下:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">

<!-- 预警信息监测 -->
<struts>
    <package name="warningInformation" extends="struts-default">
    
        <!-- 显示主界面 -->
         <action name="gotoWarningInformationSetting" class="warningInformationAction" method="gotoWarningInformationSetting">
            <result name="success">/next/warningInformation.jsp</result>
        </action>
        
    </package>
</struts>

applicationContext.xml文件

applicationContext.xml的bean可以分离出来,如:

<!-- 预警信息监测 -->
<import resource="classpath:config/bean/warningInformation-bean.xml"/>

注:import是放在</bean>标签前面的

在src下面新建 package 名为:config.bean,再新建xml文件为warningInformation-bean.xml,这样,我们就可以把预警信息监测的bean全放在warningInformation-bean.xml里面了

warningInformation-bean.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-3.0.xsd">

    <!-- 节能预警监测 -->
    <bean name="warningInformationAction" class="com.java.ssh.action.WarningInformationAction">
        <property name="warningInformationManager">
            <ref bean="warningInformationManager"/>
        </property>
    </bean>
</beans>

 

posted @ 2014-06-19 16:24  cnJun  阅读(321)  评论(0编辑  收藏  举报