• 异常:ERROR RESOLVING TEMPLATE "USERS/LIST", TEMPLATE MIGHT NOT EXIST OR MIGHT NOT BE ACCESSIBLE BY...


    SPRING.MVC调试时异常:ERROR RESOLVING TEMPLATE “USERS/LIST”, TEMPLATE MIGHT NOT EXIST OR MIGHT NOT BE ACCESSIBLE BY ANY OF THE CONFIGURED TEMPLATE RESOLVERS.

    org.thymeleaf.exceptions.TemplateInputException: Error resolving template "users/list", template might not exist or might not be accessible by any of the configured Template Resolvers
        at org.thymeleaf.engine.TemplateManager.resolveTemplate(TemplateManager.java:865) ~[thymeleaf-3.0.3.RELEASE.jar:3.0.3.RELEASE]
        at org.thymeleaf.engine.TemplateManager.parseAndProcess(TemplateManager.java:608) ~[thymeleaf-3.0.3.RELEASE.jar:3.0.3.RELEASE]
        at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1098) [thymeleaf-3.0.3.RELEASE.jar:3.0.3.RELEASE]
        at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1072) [thymeleaf-3.0.3.RELEASE.jar:3.0.3.RELEASE]
        at org.thymeleaf.spring4.view.ThymeleafView.renderFragment(ThymeleafView.java:335) [thymeleaf-spring4-3.0.3.RELEASE.jar:3.0.3.RELEASE]
        at org.thymeleaf.spring4.view.ThymeleafView.render(ThymeleafView.java:189) [thymeleaf-spring4-3.0.3.RELEASE.jar:3.0.3.RELEASE]
        at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1282) [spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
        at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1037) [spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:980) [spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897) [spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) [spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
        at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861) [spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
     
    • 项目开发环境:Eclipse+SpringBoot+thymeleaf;

    最近在学习spring boot开发系统,本地测试开发页面都能正常显示,但启动gradle项目之后,/users无法访问到,百度且尝试了很多方法,最终成功解决,把查询到的方法做一个整理,方便日后查看:

    问题一:提示模板页不存在,但实际能找到模板页,但在使用TH:INCLUDE标签的时候才会出错。

    • 解决:引用模板文件时不用“/”打头,通过类似相对路径的方式来引用,但这里的相对路径仍然是相对于模板根目录来做的。
    • @RequestMapping("/view")
      public String view()  {
          return "/view";
      }

    去掉“/”:

    return "view";

    问题二:注解错误,在CONTROLLER上加注解@CONTROLLER 和@RESTCONTROLLER都可以在前端调通接口,但是二者的区别如下:

  • 相关阅读:
    mydumper 备份工具
    k8s 二进制部署详解
    etcd+https部署
    Harbor + Https 部署
    Nginx+Tomcat+Memcache 实现session共享
    rap 部署
    Centos6.5下rsync+inotify的配置详解
    python2.7中MySQLdb的安装与使用详解
    Linux中普通用户提权为超级用户
    Mysql忘记密码
  • 原文地址:https://www.cnblogs.com/CryOnMyShoulder/p/14578782.html
Copyright © 2020-2023  润新知