没有合适的资源?快使用搜索试试~ 我知道了~
Web项目中使用Spring, 使用 Spring 的器监听器 ContextLoaderListener.docx
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 105 浏览量
2022-06-26
21:05:30
上传
评论
收藏 83KB DOCX 举报
温馨提示
试读
20页
一、Web项目中使用Spring o1. 新建一个Maven项目 o2. 使用之前的案例 o3. 定义index页面 o4. 定义RegisterServlet o5. 定义result页面 o6. web.xml 注册 Servlet o7. 运行结果分析 二、 使用 Spring 的器监听器 ContextLoaderListener o1. maven依赖pom.xml o2. 注册监听器 ContextLoaderListener o3. 指定 Spring 配置文件的位置 o4. 获取Spring容器对象 在 Web 项目中使用 Spring 框架,首先要解决在 web 层(这里指 Servlet)中获取到 Spring容器的问题。只要在 web 层获取到了 Spring 容器,便可从容器中获取到 Service 对象
资源推荐
资源详情
资源评论
Spring 与 Web
目录
� 一、Web 项目中使用 Spring
o 1. 新建一个 Maven 项目
o 2. 使用之前的案例
o 3. 定义 index 页面
o 4. 定义 RegisterServlet
o 5. 定义 result 页面
o 6. web.xml 注册 Servlet
o 7. 运行结果分析
� 二、 使用 Spring 的器监听器 ContextLoaderListener
o 1. maven 依赖 pom.xml
o 2. 注册监听器 ContextLoaderListener
o 3. 指定 Spring 配置文件的位置
o 4. 获取 Spring 容器对象
在 Web 项目中使用 Spring 框架,首先要解决在 web 层(这里指 Servlet)中
获取到 Spring 容器的问题。只要在 web 层获取到了 Spring 容器,便可从容
器中获取到 Service 对象
一、Web 项目中使用 Spring
1. 新建一个 Maven 项目
此时选择的就是 maven-archetype-webapp
2. 使用之前的案例
还是使用 Spring 集成 MyBatis 那个案例的代码,目录如下
1. service 层、Dao 层,domain 全部代码复制
2. 配置文件 applicationContext.xml、jdbc.properties,mybatis.xml,复制
3. pom.xml、主要新增加入 servlet,jsp 依赖
这里还是直接把整个的 pom.xml 文件放在下面
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/
2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/
xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.md</groupId>
<artifactId>10-spring-web</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<!-- 单元测试-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<!--spring 核心-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.2.5.RELEASE</version>
</dependency>
<!--spring 事务用到的-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>5.2.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>5.2.5.RELEASE</version>
</dependency>
<!--mybatis 的-->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.5.1</version>
</dependency>
<!--mybatis 和 spring 集成的-->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.3.1</version>
</dependency>
<!--mysql 驱动-->
<dependency>
<groupId>mysql</groupId>
剩余19页未读,继续阅读
资源评论
小兔子平安
- 粉丝: 209
- 资源: 1940
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于Python的图像阴影检测与去除源码(高分期末大作业项目).zip
- 基于C++/Qt实现的井字棋游戏
- 基于 Python 编程语言的 Web 框架Django
- Python和Flask实现的基于体检数据的城市公共健康可视分析系统源码+使用说明.zip
- 基于python实现的华为智慧工地-安全帽检测
- buck-boost_2023-12-16_12-12-13.eprj
- 后端开发关于数据库和API开发的介绍
- 机器学习和数据挖掘课程设计-米其林餐厅数据挖掘管理系统源码+使用文档说明.zip
- html html html展示我与ai的对化
- 数据结构课程设计-全国交通出行咨询模拟系统C语言实现源码.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功