设为首页 加入收藏

TOP

thymeleaf各种问题,标签没用?网页404?(一)
2019-09-17 16:28:38 】 浏览:33
Tags:thymeleaf 各种 问题 标签 没用 网页 404

首先html的网页

  

<!DOCTYPE html>
//注意这个xmlns后面一定是https,我的就是没加s导致无法识别msg这种变量
<html lang="en" xmlns:th="https://www.thymeleaf.org">

<head>
    <meta charset="UTF-8">
    <title>Thymeleaf 语法</title>
</head>
<body>


<p th:text="${msg}"></p>
</body>
</html>

  

其次,html文件基本都说是放在templates文件夹下,然后用application.properties写一下解析器(前4行应该都必要写上去)

spring.resources.static-locations=classpath:/templates/
spring.thymeleaf.cache=false
spring.thymeleaf.mode=LEGACYHTML5
spring.thymeleaf.suffix=.html
spring.thymeleaf.encoding=UTF-8

最重要的导入的包!!!!我可能这一天就死在导包上了

<properties>
        <java.version>1.8</java.version>
         <thymeleaf-layout-dialect.version>2.1.1</thymeleaf-layout-dialect.version>
        <project.build.sorceEncoding>UTF-8</project.build.sorceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>

//下面是我觉得必须要用到的包,反正我少一个就起不来,百度上的也没总结,我就自己写了
  <dependency>
            <groupId>org.thymeleaf</groupId>
            <artifactId>thymeleaf-spring5</artifactId>
            <version>3.0.11.RELEASE</version>
        </dependency>
 <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
<dependency>
            <groupId>net.sourceforge.nekohtml</groupId>
            <artifactId>nekohtml</artifactId>
        </dependency>
 <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
    <dependency>
            <groupId>org.thymeleaf</groupId>
            <artifactId>thymeleaf</artifactId>
            <version>3.0.9.RELEASE</version>
        </dependency>

  当然web的包是必要的这边也再做下累述吧。嫌自己看包麻烦想复制粘贴配置的请复制下面的

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.7.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <properties>
        <java.version>1.8</java.version>
         <thymeleaf-layout-dialect.version>2.1.1</thymeleaf-layout-dialect.version>
        <project.build.sorceEncoding>UTF-8</project.build.sorceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>

    <groupId>com.joel.shiro</groupId>
首页 上一页 1 2 3 下一页 尾页 1/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Struts2 Jsp 动态明细向后台传值 下一篇Spring MVC内容协商实现原理及自..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目