项目 >> Web 框架 >> Spring MVC

Spring MVC(Java)

Spring MVCSpring's Web MVC framework is designed around a DispatcherServlet that dispatches requests to handlers, with configurable handler mappings, view resolution, locale and theme resolution as well as support for upload files. The default handler is a very simple Controller interface, just offering a ModelAndView handleRequest(request,response) method. This can already be used for application controllers, but you will prefer the included implementation hierarchy, consisting of, for example AbstractController, AbstractCommandController and SimpleFormController. Application controllers will typically be subclasses of those. Note that you can choose an appropriate base class: if you don't have a form, you don't need a form controller. This is a major difference to Struts.

Homepage: www.springframework.org

Loading...

一种实用的Struts+Spring整合策略

这种整合策略其实非常简单,其思路是将获取业务的逻辑组件的方式放在父类中,其余的action则从父类中获取,下面是BaseAction的代码 public class BaseAction extends ActionSupport...{     public Object getBean(String beanName)...{         return...

Spring中任务调度(TimerTask篇)

在Spring中实现按时任务调度除了用Quartz之外,还可以使用TimerTask。但是TimerTask适用于时间间隔相对较短的任务,如果任务时间间隔很长,比如一天执行一次,还是用Quartz要好。 1.xml文件 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//...

Spring使用TimerTask配置调度事务

首先我们编写调度服务,继承java.util.TimerTask   package TimerTest; import java.util.Date; import java.util.TimerTask; public class TimerService extends TimerTask ...{         public void run() ...{     ...

Spring 整合 Hibernate 的一处简化配置

在过去使用 Spring 整合 Hibernate 的时候,都是用这样的配置方式。 <bean id="sessionFactory" lazy-init="true"       class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">     <property name="mappingResources&...

Spring with Tomcat 中文编码问题的解决方案

由于各种原因,Java 应用中有关中文编码的问题总是层出不穷,即使是在 i18n 发展已久的今日,为了能够在 Java 应用中良好地使用中文,程序员们仍然要花费许多额外的力气来调试、设置以解决有关中文编码的问题。针对在 Tomcat 服务器上运行的 Spring 应用,我总结了一些相关的经验,希望能帮助其他人在处理该问题时能少走一些弯路。以下条目纯属个人在开发中摸索...

Spring笔记之八(Internationalization of spring)

国际化支持在实际开发中可能是最常用的特性,本文分析Spring的 ApplicationContext 提供国际化支持, 其提供了更加强大的功能,如信息的自动装配以及热部署功能(配置文件修改后自动读取,而无需重新启动应用程序)。     目前Spring中提供了两个 MessageSource接口的实现,即ResourceBundleMessageSource和ReloadableResourceBundleMessageS...

Spring笔记之七(Types of Injection)

本文研究Spring的三种依赖注入实现类型——接口注入(Interface Injection)、设值注入(Setter Injection)、构造子注入(Constructor Injection)。 Type1 接口注入: 传统的创建接口对象的方法, 借助接口来将调用者与实现者分离。如下面的代码所示:    1 public class ClassA   2 {  3&n...

Spring笔记之六(IoC Singleton)

 Spring中BeanFactory支持两个对象模型 单态: 模型提供了具有特定名称的对象的共享实例,可以在查询时对其进行检索。Singleton 是默认的也是最常用的对象模型。对于无状态   服务对象很理想。 原型: 模型确保每次检索都会创建单独的对象。在每个用户都需要自己的对象时,原型模型最适合。 实例:  1  <  beans  &...

Spring笔记之五(Hierarchical Bean Factory Usage)

 本文研究Spring分层Bean Factory用法,先看有关代码:  1 parent.xml  2   3 <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"       "http://www.springframework.org/dtd/spring-beans.dtd">  4 <beans>  5 &n...

Spring笔记之四(Spring Event)

Spring 中提供一些Aware相关的接口,BeanFactoryAware、 ApplicationContextAware、ResourceLoaderAware、ServletContextAware等等,其中最常用到的是ApplicationContextAware。实现ApplicationContextAware的Bean,在Bean被初始后,将会被注入 ApplicationContext的实例。ApplicationContextAware 提供了publishEvent()方法,实现Observer(观察者)设计模式的事...