zoukankan      html  css  js  c++  java
  • eclipse之SSH配置spring【二】

    第一篇中配置struts完成(http://www.cnblogs.com/dev2007/p/6475074.html),在此基础上,继续配置spring。

    web.xml中增加listener,依然在节点web-app中。

    <listener>
    		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    	</listener>
    	<context-param>
    		<param-name>contextConfigLocation</param-name>
    		<param-value>classpath:applicationContext.xml</param-value>
    	</context-param>
    

     Tip:applicationContext.xml是后面在src目录自己建立的spring的配置文件。

    struts.xml中增加constant,指定spring为objectFactory,增加在struts节点中第一行,同时修改action的class为applicationContext.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.3.dtd">
    <struts>
    	<constant name="struts.objectFactory" value="spring" />
    	<package name="default" namespace="/" extends="struts-default">
    		<default-action-ref name="index"></default-action-ref>
    		<action name="index" class="homeAction">
    			<result>/WEB-INF/views/index.jsp</result>
    		</action>
    		<action name="search" class="searchAction">
    			<result>/WEB-INF/views/result.jsp</result>
    		</action>
    	</package>
    </struts>
    

     src目录中增加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"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans  
                   http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
    	<bean id="homeAction" class="com.awu.actions.HomeAction" scope="prototype">
    	</bean>
    	<bean id="searchAction" class="com.awu.actions.SearchAction"
    		scope="prototype">
    	</bean>
    </beans>
    

     最后,最重要的WEB-INF的lib中需要添加的必需jar。

    • spring-asm-3.0.5.RELEASE.jar
    • spring-beans-3.0.5.RELEASE.jar
    • spring-context-3.0.5.RELEASE.jar
    • spring-core-3.0.5.RELEASE.jar
    • spring-expression-3.0.5.RELEASE.jar
    • spring-web-3.0.5.RELEASE.jar
    • struts2-spring-plugin-2.3.24.1.jar
  • 相关阅读:
    delphi 的插件机制与自动更新
    delphi 的 ORM 框架
    canner CMS 系统 (公司在台湾) https://www.canner.io/
    区块链 ---- 数字货币交易
    BIM平台 http://gzcd.bim001.cn
    TreeGrid 控件集 :delphi 学习群 ---- 166637277 (Delphi学习交流与分享)
    UniGUI 如何进行 UniDBGrid 的单元 Cell 的计算 ?
    国产 WEB UI 框架 (收费)-- Quick UI,Mini UI
    iOS尽量不要在viewWillDisappear:方法中移除通知
    Tips:取消UICollectionView的隐式动画
  • 原文地址:https://www.cnblogs.com/dev2007/p/6477268.html
Copyright © 2011-2022 走看看