Spring框架web项目实战全代码分享

以下是一个最简单的示例

1、新建一个标准的javaweb项目

2、导入spring所需的一些基本的jar包

3、配置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">
  <!-- 应用程序Spring上下文配置 -->
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
      classpath*:applicationContext*.xml,
    </param-value>
  </context-param> 

  <!-- spring上下文加载监听器 -->
  <listener>
    <listener-class>
      org.springframework.web.context.ContextLoaderListener
    </listener-class>
  </listener>
 <welcome-file-list>
  <welcome-file>index.jsp</welcome-file>
 </welcome-file-list>
</web-app> 

4、添加spring配置文件applicationContext

5、对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" 

  default-lazy-init="false" default-autowire="byName">
  <bean id="user" class="com.po.User">
    <property name="name" value="张三"/>
  </bean>
</beans> 

beans——xml文件的根节点。

xmlns——是XMLNameSpace的缩写,因为XML文件的标签名称都是自定义的,自己写的和其他人定义的标签很有可能会重复命名,而功能却不一样,所以需要加上一个namespace来区分这个xml文件和其他的xml文件,类似于java中的package。

xmlns:xsi——是指xml文件遵守xml规范,xsi全名:xmlschemainstance,是指具体用到的schema资源文件里定义的元素所准守的规范。即/spring-beans-2.0.xsd这个文件里定义的元素遵守什么标准。

xsi:schemaLocation——是指,本文档里的xml元素所遵守的规范,schemaLocation属性用来引用(schema)模式文档,解析器可以在需要的情况下使用这个文档对XML实例文档进行校验。它的值(URI)是成对出现的,第一个值表示命名空间,第二个值则表示描述该命名空间的模式文档的具体位置,两个值之间以空格分隔。

6、新建一个实体类User.java

package com.po; 

public class User {
  private String name;
  private String age;
  public String getName() {
    return name;
  }
  public void setName(String name) {
    this.name = name;
  }
  public String getAge() {
    return age;
  }
  public void setAge(String age) {
    this.age = age;
  }
} 

7、测试

public static void main(String[] args) {
  // TODO Auto-generated method stub
  ApplicationContext ac = new FileSystemXmlApplicationContext("config/applicationContext.xml");
  User user =(User)ac.getBean("user");
  System.out.println(user.getName());
} 

输出

这就实现web项目搭建基础spring框架。接下来就做一些真正项目中会用到的一些扩展
可以在web.xml中配置一些spring框架集成的功能或其他设置

<!-- 字符编码过滤器,必须放在过滤器的最上面 -->
  <filter>
    <filter-name>encodingFilter</filter-name>
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    <init-param>
      <param-name>forceEncoding</param-name>
      <param-value>true</param-value>
    </init-param>
    <init-param>
      <param-name>encoding</param-name>
      <param-value>UTF-8</param-value>
    </init-param>
  </filter>
  <filter-mapping>
    <filter-name>encodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping> 

  <!-- 配置延迟加载时使用OpenSessionInView-->
  <filter>
    <filter-name>openSessionInViewFilter</filter-name>
    <filter-class>
    org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
    </filter-class>
    <init-param>
      <param-name>singleSession</param-name>
      <param-value>true</param-value>
    </init-param>
    <init-param>
      <param-name>sessionFactoryBeanName</param-name>
      <!--指定对Spring配置中哪个sessionFactory使用OpenSessionInView-->
      <param-value>sessionFactory</param-value>
    </init-param>
  </filter> 

  <filter-mapping>
    <filter-name>openSessionInViewFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  <!-- spring security过滤器 org.springframework.web.filter.DelegatingFilterProxy(委托过滤器代理)-->
    <!-- 使用springSecurity或apache shiro就会用到这个过滤器,-->
  <filter>
    <filter-name>springSecurityFilterChain</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>springSecurityFilterChain</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
<!-- 声明 Spring MVC DispatcherServlet -->
  <servlet>
    <servlet-name>springDispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>classpath*:spring-mvc.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet> 

  <!-- map all requests for /* to the dispatcher servlet -->
  <servlet-mapping>
    <servlet-name>springDispatcher</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>
<!-- 配置出错页面 -->
  <error-page>
    <error-code>404</error-code>
    <location>errorpage/404.jsp</location>
  </error-page>
  <!-- 401错误 -->
  <error-page>
    <error-code>401</error-code>
    <location>/errorpage/401.html</location>
  </error-page>
<!-- 为每个jsp页面引入taglib.jspf等文件 -->
  <jsp-config>
    <taglib>
      <taglib-uri>/WEB-INF/runqianReport4.tld</taglib-uri>
      <taglib-location>/WEB-INF/runqianReport4.tld</taglib-location>
    </taglib>
    <jsp-property-group>
      <url-pattern>*.jsp</url-pattern>
      <page-encoding>UTF-8</page-encoding>
      <include-prelude>/tag/taglib.jspf</include-prelude>
      <!--<trim-directive-whitespaces>true</trim-directive-whitespaces> -->
    </jsp-property-group>
  </jsp-config> 

其中jspf就是做一些全局的声明

<%@ page language="java" contentType="text/html; charset=UTF-8"
<span style="white-space:pre">  </span>pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fnc" uri="/WEB-INF/tlds/fnc.tld" %>
<%@ taglib tagdir="/WEB-INF/tags" prefix="mytag"%>
<c:set var="ctx" scope="session"
<span style="white-space:pre">  </span>value="${pageContext.request.contextPath}" /> 

可以在applicationContext.xml中配置更多的功能

<!-- beans可以添加更多声明 -->
<beans xmlns="http://www.springframework.org/schema/beans" 

  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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:context="http://www.springframework.org/schema/context" 

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

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

  http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd  

  http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd  

  http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd 

  http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd 

  http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd" 

  default-lazy-init="false" default-autowire="byName">
<!-- 使用注解定义切面 -->
  <aop:aspectj-autoproxy /> 

  <mvc:annotation-driven />
<!-- spring 注释代替配置,自动扫描的基础包,将扫描该包以及所有子包下的所有类需要把controller去掉,否则影响事务管理 --> 

  <context:component-scan base-package="com.schoolnet">
    <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" />
  </context:component-scan>
<!-- 配置系统properties配置文件 -->
<bean id="propertyConfigurer"
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="fileEncoding" value="UTF-8" />
    <property name="locations">
      <list>
        <value>classpath:jdbc.properties</value>
      </list>
    </property>
  </bean>
<!-- 数据源配置 -->
  <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" 

    destroy-method="close"> 

    <property name="driverClass" value="${jdbc.driverClassName}" /> 

    <property name="jdbcUrl" value="${jdbc.url}" /> 

    <property name="user" value="${jdbc.username}" /> 

    <property name="password" value="${jdbc.password}" /> 

    <property name="minPoolSize"> 

      <value>1</value> 

    </property> 

    <property name="maxPoolSize" value="100" /> 

    <property name="initialPoolSize" value="3" /> 

    <!--最大空闲时间,60秒内未使用则连接被丢弃。若为0则永不丢弃。Default: 0 --> 

    <property name="maxIdleTime" value="60" /> 

    <!--当连接池中的连接耗尽的时候c3p0一次同时获取的连接数。Default: 3 --> 

    <property name="acquireIncrement" value="5" /> 

    <property name="maxStatements" value="0" /> 

    <!--每60秒检查所有连接池中的空闲连接。Default: 0 --> 

    <property name="idleConnectionTestPeriod" value="60" /> 

    <!--定义在从数据库获取新连接失败后重复尝试的次数。Default: 30 --> 

    <property name="acquireRetryAttempts" value="30" /> 

    <!-- 获取连接失败将会引起所有等待连接池来获取连接的线程抛出异常。但是数据源仍有效 保留,并在下次调用getConnection()的时候继续尝试获取连接。如果设为true,那么在尝试  

      获取连接失败后该数据源将申明已断开并永久关闭。Default: false --> 

    <property name="breakAfterAcquireFailure" value="false" /> 

    <!-- 因性能消耗大请只在需要的时候使用它。如果设为true那么在每个connection提交的 时候都将校验其有效性。建议使用idleConnectionTestPeriod或automaticTestTable  

      等方法来提升连接测试的性能。Default: false --> 

    <property name="testConnectionOnCheckout" value="false" /> 

  </bean>
<!-- 定义事务管理器(声明式的事务)-->
<!-- 支持 @Transactional 标记 -->
<!-- 方式一:DataSourceTransactionManager -->
  <bean id="transactionManager" 

    class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> 

    <property name="dataSource" ref="dataSource" /> 

  </bean>
  <tx:annotation-driven transaction-manager="transactionManager"/>  

<!-- 方式二:hibernateTransactionManager -->
  <bean id="hibernateTransactionManager" 

    class="org.springframework.orm.hibernate3.HibernateTransactionManager"> 

    <property name="sessionFactory"> 

      <ref local="sessionFactory" /> 

    </property> 

  </bean>
  <!-- 配置hibernate的session工厂 --> 

  <bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="lobHandler" ref="lobHandler"/>
    <property name="mappingLocations">
      <list>
        <value>classpath*:/com/schoolnet/**/*.hbm.xml</value>
      </list>
    </property>
    <property name="hibernateProperties">
      <props>
        <!-- 解决在Oracle多个表空间表名相同导致hibernate不会自动生成表 -->
        <prop key="hibernate.default_schema">${jdbc.username}</prop>
        <prop key="hibernate.dialect">
          org.hibernate.dialect.Oracle10gDialect
        </prop>
        <prop key="hibernate.show_sql">true</prop>
        <!--解决内存泄漏问题 -->
        <prop key="hibernate.generate_statistics">false</prop>
        <prop key="hibernate.connection.release_mode">
          auto
        </prop>
        <prop key="hibernate.autoReconnect">true</prop>
        <prop key="hibernate.cache.provider_class">
          org.hibernate.cache.EhCacheProvider
        </prop>
        <!--解决内存泄漏问题 -->
        <prop key="hibernate.cache.use_query_cache">false</prop>
        <prop key="use_second_level_cache">false</prop>
         <prop key="hibernate.hbm2ddl.auto">update</prop>
        <prop key="current_session_context_class">thread</prop>
      </props>
    </property>
    <property name="eventListeners">
      <map>
        <entry key="merge">
          <bean
            class="org.springframework.orm.hibernate3.support.IdTransferringMergeEventListener" />
        </entry>
      </map>
    </property>
  </bean>
<!--2.配置Hibernate事务特性 -->
  <tx:advice id="txAdvice" transaction-manager="hibernateTransactionManager">
    <tx:attributes>
      <tx:method name="save*" propagation="REQUIRED" rollback-for="Exception" />
      <tx:method name="add*" propagation="REQUIRED" rollback-for="Exception" />
      <tx:method name="update*" propagation="REQUIRED" rollback-for="Exception" />
      <tx:method name="modify*" propagation="REQUIRED" rollback-for="Exception" />
      <tx:method name="del*" propagation="REQUIRED" rollback-for="Exception" />
      <tx:method name="start*" propagation="REQUIRED" rollback-for="Exception" />
      <tx:method name="stop*" propagation="REQUIRED" rollback-for="Exception" />
      <tx:method name="assign*" propagation="REQUIRED" rollback-for="Exception" />
      <tx:method name="clear*" propagation="REQUIRED" rollback-for="Exception" />
      <tx:method name="execute*" propagation="REQUIRED" rollback-for="Exception" />
      <tx:method name="insert*" propagation="REQUIRED" rollback-for="Exception" />
      <tx:method name="do*" propagation="REQUIRED" rollback-for="Exception" />
      <tx:method name="set*" propagation="REQUIRED" rollback-for="Exception" />
      <tx:method name="*N" propagation="NEVER" />
      <tx:method name="*" read-only="true"/>
    </tx:attributes>
  </tx:advice>
<!-- 配置那些类的方法进行事务管理 -->
  <aop:config>
    <aop:advisor pointcut="execution(* com.eshine..*.service.*.*(..))"
      advice-ref="txAdvice" />
  </aop:config> 

spring-mvc.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:jee="http://www.springframework.org/schema/jee"
  xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
  xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc"
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
  http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd
  http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
  http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
  http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
  http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"> 

  <context:component-scan base-package="com.schoolnet" use-default-filters="false">
    <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" />
  </context:component-scan>
  <mvc:annotation-driven />
  <mvc:default-servlet-handler />
  <!-- jsp视图解析器 -->
  <bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/" />
    <property name="suffix" value=".jsp" />
    <property name="order" value="0" />
    <property name="contentType" value="text/html;charset=UTF-8" />
  </bean>
   <!--多文上传,限制1G文件 -->
  <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
    <property name="maxUploadSize" value="1073741824" />
  </bean>
</beans> 

总结

以上就是本文关于Spring框架web项目实战全代码分享的全部内容,希望对大家有所帮助。感兴趣的朋友可以继续参阅本站:

springmvc Rest风格介绍及实现代码示例

SpringMVC拦截器实现单点登录

Spring集成Redis详解代码示例

如有不足之处,欢迎留言指出。感谢朋友们对本站的支持!

(0)

相关推荐

  • 详解Java的MyBatis框架与Spring框架整合中的映射器注入

    MyBatis-Spring允许你在Service Bean中注入映射器.当使用映射器时,就像调用DAO那样来调用映射器就可以了,但是此时你就不需要进行任何DAO实现的编码,因为MyBatis会为你进行. 使用注入的映射器,你的代码就不会出现任何MyBatis-Spring依赖和MyBatis依赖.在我们的应用中有这样一个简单的映射器.你也应该知道映射器仅仅是一个接口: public interface UserMapper { User getUser(String userId); } 这是

  • 深入理解Java的Spring框架中的IOC容器

    Spring IOC的原型 spring框架的基础核心和起点毫无疑问就是IOC,IOC作为spring容器提供的核心技术,成功完成了依赖的反转:从主类的对依赖的主动管理反转为了spring容器对依赖的全局控制. 这样做的好处是什么呢? 当然就是所谓的"解耦"了,可以使得程序的各模块之间的关系更为独立,只需要spring控制这些模块之间的依赖关系并在容器启动和初始化的过程中将依据这些依赖关系创建.管理和维护这些模块就好,如果需要改变模块间的依赖关系的话,甚至都不需要改变程序代码,只需要将

  • 详解Java的MyBatis框架和Spring框架的整合运用

    单独使用mybatis是有很多限制的(比如无法实现跨越多个session的事务),而且很多业务系统本来就是使用spring来管理的事务,因此mybatis最好与spring集成起来使用. 版本要求 项目 版本 下载地址 说明 mybatis 3.0及以上 https://github.com/mybatis/mybatis-3/releases spring 3.0及以上 http://projects.spring.io/spring-framework/ mybatis-spring 1.0

  • Java的MyBatis+Spring框架中使用数据访问对象DAO模式的方法

    SqlSessionTemplate SqlSessionTemplate是MyBatis-Spring的核心.这个类负责管理MyBatis的SqlSession,调用MyBatis的SQL方法,翻译异常.SqlSessionTemplate是线程安全的,可以被多个DAO所共享使用. 当调用SQL方法时,包含从映射器getMapper()方法返回的方法,SqlSessionTemplate将会保证使用的SqlSession是和当前Spring的事务相关的.此外,它管理session的生命周期,包

  • Java Web程序中利用Spring框架返回JSON格式的日期

    返回Json时格式化日期Date 第一步:创建CustomObjectMapper类 /** * 解决SpringMVC使用@ResponseBody返回json时,日期格式默认显示为时间戳的问题.需配合<mvc:message-converters>使用 */ @Component("customObjectMapper") public class CustomObjectMapper extends ObjectMapper { public CustomObject

  • Spring框架生成图片验证码实例

    这篇文章会从前台页面到后台实现完整的讲解,下面跟着小编一起来看看. 1.前台的代码,image.jsp <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" &quo

  • Spring框架中 @Autowired 和 @Resource 注解的区别

    Spring框架中 @Autowired 和 @Resource 注解的区别 在 spring 框架中,除了使用其特有的注解外,使用基于 JSR-250 的注解,它包括 @PostConstruct, @PreDestroy 和 @Resource 注释. 首先,咱们简单了解 @PostConstruct 和 @PreDestroy 注释: 为了定义一个 bean 的安装和卸载,我们可以使用 init-method 和 destroy-method 参数简单的声明一下 ,其中 init-meth

  • spring框架下websocket的搭建

    本文基于Apach Tomcat 8.0.3+MyEclipse+maven+JDK1.7 spring4.0以后加入了对websocket技术的支持,撸主目前的项目用的是SSM(springMVC+spring+MyBatis)框架,所以肯定要首选spring自带的websocket 1 在maven的pom.xml中加入websocket所依赖的jar包 <dependency> <groupId>com.fasterxml.jackson.core</groupId&g

  • Spring框架web项目实战全代码分享

    以下是一个最简单的示例 1.新建一个标准的javaweb项目 2.导入spring所需的一些基本的jar包 3.配置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/

  • JavaScript中全选、全不选、反选、无刷新删除、批量删除、即点即改入库(在yii框架中操作)的代码分享

    效果展示: 代码实现: 控制器 <?php namespace app\controllers; use Yii; use yii\filters\AccessControl; use yii\web\Controller; use yii\filters\VerbFilter; use app\models\LoginForm; use app\models\ContactForm; //use yii\db\ActiveRecord; use yii\data\Pagination; use

  • IDEA 中创建Spring Data Jpa 项目的示例代码

    一.IDEA 创建工程 使用IDEA 创建工程的过程,使用文字做简单描述. 选择工程类别[Spring Initializr]. 设置工程的元数据[Metadata],根据自己的情况填写即可. 设置工程的依赖:在[Web]中选择"Spring Web";在[SQL]中选中"Spring Data JPA"."Spring Data JDBC"."MySQL Driver"."JDBC API".选中的可能有

  • Java Spring框架创建项目与Bean的存储与读取详解

    目录 1.Spring项目的创建 1.1创建Maven项目 1.2添加spring依赖 1.3创建启动类 1.4配置国内源 2.储存或读取Bean对象 2.1添加spring配置文件 2.2创建Bean对象 2.3读取Bean对象 本文思维导图: 1.Spring项目的创建 1.1创建Maven项目 第一步,创建Maven项目,Spring也是基于Maven的. 1.2添加spring依赖 第二步,在Maven项目中添加Spring的支持(spring-context, spring-beans

  • 通过简单方法实现spring boot web项目

    搭建效果为: 直接在网页输入请求,在页面中显示一行文字:Hello,Spring Boot 与一般的wen项目不同的地方: 1.不需要配置web.xml 文件,但需要注解@SpringBootApplication 等 2.一切和spring有关的jar包都不需要版本号,springcloud会给你选择它最稳定的版本 3.它会定位public static void main()方法来标记为可运行类,必须在主路径下 4.启动方式: a.右键运行main方法 b.由于我们使用了 spring-bo

  • 详解Spring Boot Web项目之参数绑定

    一.@RequestParam 这个注解用来绑定单个请求数据,既可以是url中的参数,也可以是表单提交的参数和上传的文件 它有三个属性,value用于设置参数名,defaultValue用于对参数设置默认值,required为true时,如果参数为空,会报错 好,下面展示具体例子: 首先是vm: <h1>param1:${param1}</h1> <h1>param2:${param2}</h1> 好吧,就为了展示两个参数 第一种情况: @RequestMa

  • Spring框架七大模块简单介绍

    Spring 是一个开源框架,是为了解决企业应用程序开发复杂性而创建的.框架的主要优势之一就是其分层架构,分层架构允许您选择使用哪一个组件,同时为 J2EE 应用程序开发提供集成的框架. Spring框架的7个模块 组成 Spring框架的每个模块(或组件)都可以单独存在,或者与其他一个或多个模块联合实现.每个模块的功能如下: 1核心模块 SpringCore模块是Spring的核心容器,它实现了IOC模式,提供了Spring框架的基础功能.此模块中包含的BeanFactory类是Spring的

  • Spring之WEB模块配置详解

    Spring框架七大模块简单介绍 Spring中MVC模块代码详解 Spring的WEB模块用于整合Web框架,例如Struts1.Struts2.JSF等 整合Struts1 继承方式 Spring框架提供了ActionSupport类支持Struts1的Action.继承了ActionSupport后就能获取Spring的BeanFactory,从而获得各种Spring容器内的各种资源 import org.springframework.web.struts.ActionSupport;

  • spring框架集成flyway项目的详细过程

    什么是Spring Spring是一个开源框架,它由Rod Johnson创建.它是为了解决企业应用开发的复杂性而创建的. Spring使用基本的JavaBean来完成以前只可能由EJB完成的事情.   然而,Spring的用途不仅限于服务器端的开发.从简单性.可测试性和松耦合的角度而言,任何Java应用都可以从Spring中受益.    目的:解决企业应用开发的复杂性    功能:使用基本的JavaBean代替EJB,并提供了更多的企业应用功能    范围:任何Java应用    它是一个容器

  • Spring框架设值注入操作实战案例分析

    本文实例讲述了Spring框架设值注入操作.分享给大家供大家参考,具体如下: 一 配置 <?xml version="1.0" encoding="GBK"?> <!-- Spring配置文件的根元素,使用spring-beans-4.0.xsd语义约束 --> <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http:

随机推荐