设为首页 加入收藏

TOP

基于springMVC 3.0项目开发实例(一)
2014-11-23 19:17:51 】 浏览:1834
Tags:基于 springMVC 3.0 项目 开发实例

1.项目包结构如下:

\

\

\

2. spring配置文件springMVC.xml修改如下:


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














3. spring配置文件beans.xml内容修改如下:


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





















classpath:com/sxt/domain/



org.hibernate.dialect.MySQLInnoDBDialect
true
update
























4. web.xml文件不变


xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">



contextConfigLocation
classpath:beans.xml


org.springframework.web.context.ContextLoaderListener



action
org.springframework.web.servlet.DispatcherServlet

contextConfigLocation
classpath:springMVC.xml



action
/


index.jsp


5. 类的代码不变。

6. 运行,测试。跟上一个项目保持一致。

Spring MVC 3.0 深入

核心原理

1. 用户发送请求给服务器。url:user.do

2. 服务器收到请求。发现DispatchServlet可以处理。于是调用DispatchServlet。

3. DispatchServlet内部,通过HandleMapping检查这个url有没有对应的Controller。如果有,则调用Controller。

4. Controller开始执行。

5. Controller执行完毕后,如果返回字符串,则ViewResolver将字符串转化成相应的视图对象;如果返回ModelAndView对象,该对象本身就包含了视图对象信息。

6. DispatchServlet将执视图对象中的数据,输出给服务器。

7. 服务器将数据输出给客户端。

spring3.0中相关jar包的含义

org.springframework.aop-3.0.3.RELEASE.jar

spring的aop面向切面编程

org.springframework.asm-3.0.3.RELEASE.jar

spring独立的asm字节码生成程序

org.springframework.beans-3.0.3.RELE

首页 上一页 1 2 3 4 5 6 7 下一页 尾页 1/8/8
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇ftk学习记(list篇) 下一篇策略模式Strategy――回家乘什么..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目