我如何将我的页面与控制器连接起来
How can i connect my page with Controller
我在这里尝试使用 EventController 创建一个新页面并连接到 thymeleaf
@Controller
public class EventController {
@RequestMapping(value = "/pereschet", method = RequestMethod.GET)
public String welcome() {
return "boom";
}
}
这是我的 html 页面 boom.html
<html xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout"
xmlns:sec="http://www.thymeleaf.org/extras/spring-security"
layout:decorator="layout">
<head>
<title>Index</title>
</head>
<body>
<h1 >Boombom</h1>
</body>
</html>
当我到达 /timetracking/compensatory/boom 时提示未找到错误
错误是解析模板“boom”时出错,模板可能不存在或可能无法被任何已配置的模板解析器访问
我想要工作页面,有什么想法吗?
thymeleaf 的默认模板目录是 src/main/resources/templates。请确保您已将 boom.html 放置在此目录中,因为根据您的问题没有模板解析器。请查看我在网上找到的这个 link,了解有关自定义模板解析器的详细信息。 Spring Boot with Thymeleaf
我在这里尝试使用 EventController 创建一个新页面并连接到 thymeleaf
@Controller
public class EventController {
@RequestMapping(value = "/pereschet", method = RequestMethod.GET)
public String welcome() {
return "boom";
}
}
这是我的 html 页面 boom.html
<html xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout"
xmlns:sec="http://www.thymeleaf.org/extras/spring-security"
layout:decorator="layout">
<head>
<title>Index</title>
</head>
<body>
<h1 >Boombom</h1>
</body>
</html>
当我到达 /timetracking/compensatory/boom 时提示未找到错误 错误是解析模板“boom”时出错,模板可能不存在或可能无法被任何已配置的模板解析器访问
我想要工作页面,有什么想法吗?
thymeleaf 的默认模板目录是 src/main/resources/templates。请确保您已将 boom.html 放置在此目录中,因为根据您的问题没有模板解析器。请查看我在网上找到的这个 link,了解有关自定义模板解析器的详细信息。 Spring Boot with Thymeleaf