zoukankan      html  css  js  c++  java
  • 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>
  • 相关阅读:
    mac上命令行解压rar
    Mac上安装PHP、Apache、MySQL
    8款不错的 CI/CD工具
    Apache 强制Http跳转Https
    使用MySQL的mysqldump命令备份数据库和把数据库备份文件恢复
    MySQL主从复制和读写分离
    Nginx参数调优
    【原创】深入理解Docker容器和镜像 -- 分析了docker的命令含义
    Elasticsearch使用备忘
    通过HTTP RESTful API 操作elasticsearch搜索数据
  • 原文地址:https://www.cnblogs.com/cnJun/p/3796938.html
Copyright © 2011-2022 走看看