首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Thymeleaf + springboot不能协同工作

Thymeleaf + springboot不能协同工作
EN

Stack Overflow用户
提问于 2016-10-19 05:38:49
回答 1查看 1.2K关注 0票数 0

我想用带胸腺叶子的弹力靴。我创建了一个控制器,如下所示:

我的项目结构是这样的:

代码语言:javascript
复制
package com.mbtimeet.controllers;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;


@Controller
public class HomeController {

@RequestMapping("/hello")
public String index(){
    return "index";
}
}

我有一个index.html:

代码语言:javascript
复制
<!DOCTYPE html>
<html xmlns:th=“http://www.thymeleaf.org”         xmlns="http://www.w3.org/1999/html">
<head>
</head>
<body>
Hi there.
</body>
</html>

但它就是不起作用。在我打开"http://localhost:8080/hello“页面后,我得到了一个异常。

日志:http://pastebin.com/MLPgpqph

Build.gradle:

代码语言:javascript
复制
buildscript {
    ext {
        springBootVersion = '1.4.1.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'spring-boot'

jar {
    baseName = 'mbti-meet'
    version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
    mavenCentral()
}


dependencies {
    compile('org.springframework.boot:spring-boot-starter-thymeleaf')
    compile('org.springframework.boot:spring-boot-starter-web')
    compile("org.springframework.boot:spring-boot-devtools")
    testCompile('org.springframework.boot:spring-boot-starter-test')
}

错误:

代码语言:javascript
复制
2016-10-18 22:58:15.413 ERROR 4896 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateInputException: Exception parsing document: template="index", line 2 - column 16] with root cause

我遵循了一个教程,唯一的区别是用户使用的是maven。

EN

回答 1

Stack Overflow用户

发布于 2016-10-19 13:11:20

日志消息准确地告诉您问题所在。由于某些原因,当您创建index.html文件时,xmlns:th=“http://www.thymeleaf.org”得到的是UTF8格式的引号,而不是ascii格式的"。因此,Thymeleaf在解析文件时遇到了问题。将属性更新为xmlns:th="http://www.thymeleaf.org"

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40118541

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档