我有一个简单的控制器,可以处理请求放置的数据并重定向到视图
@Controller
@RequestMapping("/ts")
public class MainController {
@GetMapping("/initiate/{templateName}")
public String getTemplate(Model model, @PathVariable("templateName") String templateName) throws IOException {
model.addAllAttributes(new ObjectMapper().readValue("{ \"dy_t1\": \"This is the text 2\" , \"dy_Lorem\":\"This is the lorem text\"}", HashMap.class));
return templateName;
}
}
当我打电话给http://localhost:8092/ts/initiate/greeting时,它正好登陆问候模板,并显示带有填充数据的页面。
greeting.html
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Getting Started: Serving Web Content</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<a href="#"><img src="logo-mobile@2x.png" /></a>
<p th:text="'Hello, ' + ${dy_t1} + '!'" />
</body>
</html>
但是当我签入控制台时,它说:
org.thymeleaf.exceptions.TemplateInputException:解决模板“ logo-mobile@2x.png”时出错,模板可能不存在,或者任何已配置的模板解析器都无法访问该模板
为什么要尝试解析greeting.html的src中存在的.png文件,如果我删除了此src,则不会推送此错误。