tags: Java framework maven spring
First, create a Module module

Second, write the following code in the POM.xml file:
<packaging>war</packaging>
<dependencies>
<!-- SpringMVC -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.3.1</version>
</dependency>
<! - log ->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>
<!-- ServletAPI -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<! - Spring5 and thymeleaf integration package ->
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring5</artifactId>
<version>3.0.12.RELEASE</version>
</dependency>
</dependencies>
Third, refresh the Maven

Create a web file and see XML configuration file


Fourth, the following configuration is made in the web.xml file:
<servlet>
<servlet-name>SpringMVC</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:springMVC.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>SpringMVC</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
5. The following configuration is made in the SpringMVC.xml file under the resource package:
<?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:context=“http://www.springframework.org/schema/context”
xsi:schemaLocation=“http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd”
Scanning component
Context components need to be configured in Beans, such as XMLns: context = "http://www.springframework.org/schema/context, do not remember to configure
<context:component-scan base-package=“com.atguigu.mvc.controller”></context:component-scan
Configure the Thymeleaf view parser
<bean id=“viewResolver”
class=“org.thymeleaf.spring5.view.ThymeleafViewResolver”
<property name=“order” value=“1”/
<property name=“characterEncoding” value=“UTF-8”/
<property name=“templateEngine”
<bean class=“org.thymeleaf.spring5.SpringTemplateEngine”
<property name=“templateResolver”
<bean
class=“org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver”
<property name=“prefix” value=”/WEB-INF/templates/"/
<property name=“suffix” value=".html"/
<property name=“templateMode” value=“HTML5”/
<property name=“characterEncoding” value=“UTF-8” /
</bean
</property
</bean
/property
/bean
/beans
The above code has some questions on parentheses, the format is not good, remember to change it.
! [Insert Picture description here] (https://img-blog.csdnimg.cn/1847499208b84c469c766b83cc9388d8.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L0pTVUlURExXWEw=,size_16,color_FFFFFF,t_70)
Such an environment is a good, you can create a class in Java for testing:

Create INDEX.html in the Templates under WebAPP under WebApp, why is it in Templates under WebApp?
Because you are configured with the following path in SpringMvc.xml:

1. Create a data table: 2. Database configuration: ①. Create a "config.properties" file in the resources directory: ②, configuration under the config directory: A. Configure constants in con...
turn:https://bbs.pediy.com/thread-251740.htm This article combs the evolution history of black IP resources, and focuses on the threat hunters' research on M2D technology and resources, as well as how...
QQ Database Management...
commonJS In 2009, American programmer Ryan Dahl creatednode.jsProject, using javascript language for server-side programming. This marks the official birth of "Javascript Modular Programming"...
Implicit conversion function Definition: declare with implicit keyword Role: Enrich the functions of existing class libraries and enhance class methods...
This time is an experimental operation. The Flink version is 1.13.3, the MySQL-CDC version is 2.0.2, and the MySQL version is 8.0.25. Step 1: Use CDC to read the two tables in the library. One detail ...
First check the disk information lsblk It can be seen that SDA3 under SDA is now mounted under / DATA1, and other disks under SDA have not been mounted in Ubuntu. Temporary mount (restart will cancel ...
MIT6.828_HW10_Bigger file for xv6 The current xv6 file size is limited to 140 sectors. There are 12 direct index nodes, and a first-level index node, which points to a sector, which can contain 512/4 ...
Vue project Vue + restfulframework Login achieve certification - django views setting urls - Vue Installation package cnpm install --save axios vuex npm install vue-cookie --save route.js store.js mai...