spring boot部署中一个斜杠引发的纠结--org.thymeleaf.exceptions.TemplateInputException
异常现象:在本地打包部署完全没有问题,资源文件也都可以映射上,但是打包成jar包部署到服务器上时,就一直报异常,异常信息如下:
-
严重: Servlet.service() for servlet [dispatcherServlet] in context with path [] -
threw exception [Request processing failed; nested exception is org.thymeleaf.ex -
ceptions.TemplateInputException: Error resolving template "/emailInfoManager/ema -
ilInfoList", template might not exist or might not be accessible by any of the c -
onfigured Template Resolvers] with root cause -
org.thymeleaf.exceptions.TemplateInputException: Error resolving template "/emai -
lInfoManager/emailInfoList", template might not exist or might not be accessible -
by any of the configured Template Resolvers -
at org.thymeleaf.TemplateRepository.getTemplate(TemplateRepository.java: -
246) -
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1104) -
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1060) -
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1011) -
at org.thymeleaf.spring4.view.ThymeleafView.renderFragment(ThymeleafView -
.java:335)
工程结构如下:
controller示例如下:
-
@RequestMapping(value = "/findEmailInfoDataCriteria", method = RequestMethod.GET) -
public String findEmailInfoDataCriteria(@RequestParam(value = "page", defaultValue = "0") Integer page, -
@RequestParam(value = "size", defaultValue = "10") Integer size, -
@ModelAttribute("emailInfoData") EmailInfo emailInfo, ModelMap modelMap) { -
Page<EmailInfo> list = emailService.findEmailDataCriteria(page, size, emailInfo); -
modelMap.addAttribute("datas", list); -
return "/emailInfoManager/emailInfoList"; -
}
经过大量的排查,最终的问题出在return "/emailInfoManager/emailInfoList";这行代码,去掉最前面的"/"就好了!
---------------------------
如果解决了您的问题,请有烦,github多点star。 算是对本人的感谢,鼓励作者继续帮助大家:
更多多技术关注,请follow本人的gith, 多给一些star