Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception...

  • 控制台报错
2019-08-02 10:39:27,390 - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateInputException: Error resolving template [/part/addUser], template might not exist or might not be accessible by any of the configured Template Resolvers] with root cause
org.thymeleaf.exceptions.TemplateInputException: Error resolving template [/part/addUser], template might not exist or might not be accessible by any of the configured Template Resolvers
  • postman 报错
 "message": "Error resolving template [/part/addUser], template might not exist or might not be accessible by any of the configured Template Resolvers",
  • 报错背景:项目在本地正常运行,打成 jar 包之后,在服务器端,疯狂报错,就是找不到路径
  • 原因:返回model的时候
	@GetMapping("/adduser")
    public ModelAndView addUser() {
        return new ModelAndView("/part/addUser");
    }
  • /part/addUser,一定要吧返回视图路径的第一个/给去掉,
  • 正解:
	@GetMapping("/adduser")
    public ModelAndView addUser() {
        return new ModelAndView("part/addUser");
    }

你可能感兴趣的:(javaweb初长成)