異常現象:在本地打包部署徹底沒有問題,資源文件也均可以映射上,可是打包成jar包部署到服務器上時,就一直報異常,異常信息以下:java
- 嚴重: 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)
工程結構以下:spring
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";這行代碼,去掉最前面的"/"就行了!app