springmvc 整合 thymeleaf
2021-06-05 21:04
标签:scan param default not servlet drive pre coding startup 添加依赖 web.xml applicationContext.xml springmvc 整合 thymeleaf 标签:scan param default not servlet drive pre coding startup 原文地址:https://www.cnblogs.com/rchao/p/14619901.htmldependency>
groupId>org.springframeworkgroupId>
artifactId>spring-webmvcartifactId>
version>5.3.5version>
dependency>
dependency>
groupId>org.thymeleafgroupId>
artifactId>thymeleafartifactId>
version>3.0.12.RELEASEversion>
dependency>
dependency>
groupId>org.thymeleafgroupId>
artifactId>thymeleaf-spring5artifactId>
version>3.0.12.RELEASEversion>
dependency>
xml version="1.0" encoding="UTF-8"?>
web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
servlet>
servlet-name>servlet-mvcservlet-name>
servlet-class>org.springframework.web.servlet.DispatcherServletservlet-class>
init-param>
param-name>contextConfigLocationparam-name>
param-value>classpath:applicationContext.xmlparam-value>
init-param>
load-on-startup>1load-on-startup>
servlet>
servlet-mapping>
servlet-name>servlet-mvcservlet-name>
url-pattern>/url-pattern>
servlet-mapping>
filter>
filter-name>characterEncodingfilter-name>
filter-class>org.springframework.web.filter.CharacterEncodingFilterfilter-class>
init-param>
param-name>encodingparam-name>
param-value>UTF-8param-value>
init-param>
filter>
filter-mapping>
filter-name>characterEncodingfilter-name>
url-pattern>/*url-pattern>
filter-mapping>
session-config>
session-timeout>30session-timeout>
session-config>
web-app>
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/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc
https://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context
https://www.springframework.org/schema/context/spring-context.xsd">
mvc:annotation-driven/>
mvc:default-servlet-handler/>
context:component-scan base-package="com.chao"/>
bean id="templateResolver" class="org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver">
property name="prefix" value="/WEB-INF/views/" />
property name="suffix" value=".html" />
property name="templateMode" value="HTML5" />
property name="cacheable" value="false" />
property name="characterEncoding" value="UTF-8" />
bean>
bean id="templateEngine" class="org.thymeleaf.spring5.SpringTemplateEngine">
property name="templateResolver" ref="templateResolver" />
bean>
bean id="viewResolver" class="org.thymeleaf.spring5.view.ThymeleafViewResolver">
property name="templateEngine" ref="templateEngine" />
property name="characterEncoding" value="UTF-8" />
bean>
beans>
上一篇:python 练习题-去重排序
下一篇:Java入门之04-Java方法
文章标题:springmvc 整合 thymeleaf
文章链接:http://soscw.com/index.php/essay/90976.html