SpringBoot部署到服务器(用jar),访问页面报错?

这个错误怎么解决,服务有启动,部署在windows上。 在服务器上访问 http://127.0.0.1:8080/admin/index 。这个请求会跳去后台的首页。但报错:

org.thymeleaf.exceptions.TemplateInputException: Error resolving template [/inde
x], template might not exist or might not be accessible by any of the configured
 Template Resolvers

.yml 配置是这样,这个有关系吗? 在本地开发是没问题的,但打包上去就报错

thymeleaf:
    prefix: classpath:/templates/
    suffix: .html
    mode: LEGACYHTML5
    encoding: UTF-8
    servlet:
      content-type: text/html
    cache: false
    check-template-location: true
    templates_root: src/main/resources/templates/
阅读 3.8k
2 个回答

controller 的return “/index” 改成 return "index";就好了

controller层请求返回数据时,没有使用注解@RestController或注解@ResponseBody返回了非json格式的数据。

返回的数据thymeleaf模板不能解析

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题