1. 程式人生 > 實用技巧 >Exception processing template "success": Exception parsing document: template="success",

Exception processing template "success": Exception parsing document: template="success",

程式碼很簡單

package com.kele.controller;

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

@Controller
public class HelloController {

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

一個超簡單的html頁面

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>success</title>
</head>
<body>
<h1>success</h1>
</body>
</html>

啟動springBoot之後,訪問http://localhost:8080/success提示以下內容:

Exception processing template "success": Exception parsing document: template="success",

解決辦法,修改html檔案的<meta>標籤

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<title>success</title>
</head>
<body>
<h1>success</h1>
</body>
</html>

重新啟動,正常訪問