mirror of
https://gitee.com/coder-xiaomo/java-note
synced 2025-01-10 19:48:15 +08:00
2
This commit is contained in:
parent
5f257ea712
commit
e17ab2eb94
BIN
张博凯的Java学习笔记.assets/image-20220120161453418.png
Normal file
BIN
张博凯的Java学习笔记.assets/image-20220120161453418.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
@ -659,15 +659,7 @@ src/main/resources/applicationContext.xml
|
||||
>
|
||||
> 添加完后,重启idea即可
|
||||
|
||||
|
||||
|
||||
##### 配置SpringMVC
|
||||
|
||||
###### 导入依赖
|
||||
|
||||
- spring-context
|
||||
- spring-jdbc
|
||||
- spring-
|
||||
接下来,[配置SpringMVC](#配置SpringMVC)
|
||||
|
||||
|
||||
|
||||
@ -4116,6 +4108,70 @@ public class UserService {
|
||||
|
||||
|
||||
|
||||
##### 配置SpringMVC
|
||||
|
||||
###### 导入依赖
|
||||
|
||||
> 所需依赖(导入spring-webmvc就可包含以下四个依赖)
|
||||
>
|
||||
> - spring-context
|
||||
> - spring-jdbc
|
||||
> - spring-web
|
||||
> - spring-webmvc
|
||||
|
||||
导入spring-webmvc依赖
|
||||
|
||||
https://mvnrepository.com/artifact/org.springframework/spring-webmvc/5.2.19.RELEASE
|
||||
|
||||
```xml
|
||||
<!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-webmvc</artifactId>
|
||||
<version>5.2.19.RELEASE</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
|
||||
|
||||
###### 创建SpringMVC配置文件
|
||||
|
||||
在resources目录下创建名为spring-servlet.xml文件(使用spring模板),并修改头部+配置
|
||||
|
||||
src/main/resources/spring-servlet.xml
|
||||
|
||||
```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:mvc="http://www.springframework.org/schema/mvc"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="
|
||||
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.xsd
|
||||
http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<!-- 声明注解配合 IOC -->
|
||||
<context:annotation-config></context:annotation-config>
|
||||
|
||||
<!-- 扫描注解的包 -->
|
||||
<context:component-scan base-package="org.example.web"></context:component-scan>
|
||||
</beans>
|
||||
```
|
||||
|
||||
> 右上角点一下Create new application context
|
||||
>
|
||||
> ![image-20220120161453418](张博凯的Java学习笔记.assets/image-20220120161453418.png)
|
||||
|
||||
|
||||
|
||||
添加mvc命名空间
|
||||
|
||||
|
||||
|
||||
#### Thymeleaf
|
||||
|
||||
> 模板引擎
|
||||
|
Loading…
Reference in New Issue
Block a user