【发布时间】:2017-02-28 08:02:47
【问题描述】:
我想将 springboot 与 thymeleaf 一起使用。我创建了一个控制器,如下所示:
我有这样的项目结构:
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:
<!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
构建.gradle:
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')
}
错误:
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。
【问题讨论】:
-
请复制您帖子中的错误;只是错误而不是整个日志。
标签: jsp spring-mvc intellij-idea spring-boot thymeleaf