目录
1 新建模块spring_listener com.atguigu
- <listener>
-
- <listenerclass>org.springframework.web.context.ContextLoaderListenerlistener-class>
- listener>
-
- <context-param>
- <param-name>contextConfigLocationparam-name>
- <param-value>classpath:spring.xmlparam-value>
- context-param>
war org.springframework spring-webmvc 5.3.1 ch.qos.logback logback-classic 1.2.3 javax.servlet javax.servlet-api 3.1.0 provided org.thymeleaf thymeleaf-spring5 3.0.12.RELEASE

- <servlet>
- <servlet-name>SpringMVCservlet-name>
- <servlet-class>org.springframework.web.servlet.DispatcherServletservlet-class>
- <init-param>
- <param-name>contextConfigLocationparam-name>
- <param-value>classpath:springmvc.xmlparam-value>
- init-param>
- <load-on-startup>1load-on-startup>
- servlet>
- <servlet-mapping>
- <servlet-name>SpringMVCservlet-name>
- <url-pattern>/url-pattern>
- servlet-mapping>
-
- <listener>
-
- <listener-class>org.springframework.web.context.ContextLoaderListenerlistener-class>
- listener>
-
- <context-param>
- <param-name>contextConfigLocationparam-name>
- <param-value>classpath:spring.xmlparam-value>
- context-param>
- "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"
- xmlns:mvc="http://www.springframework.org/schema/mvc"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd">
-
-
- <context:component-scan base-package="com.atguigu.controller">context:component-scan>
-
-
- <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>
-
- <mvc:annotation-driven />
-
- <mvc:view-controller path="/" view-name="index">mvc:view-controller>
-
- beans>
- "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 https://www.springframework.org/schema/context/spring-context.xsd">
-
-
- <context:component-scan base-package="com.atguigu.service.impl">context:component-scan>
-
- beans>
- html>
- <html lang="en" xmlns:th="http://www.thymeleaf.org">
- <head>
- <meta charset="UTF-8">
- <title>首页title>
- head>
- <body>
- <h1>index.htmlh1>
- body>
- html>
- package com.atguigu.controller;
-
- @Controller
- public class HelloController {
-
- @Autowired
- private HelloService helloService;
-
- }
- package com.atguigu.service;
-
- public interface HelloService {
- }
- package com.atguigu.service.impl;
-
- @Service
- public class HelloServiceImpl implements HelloService {
- }
