访问页面只返回字符串

查看controller中是否注解了@RestController将其修改注解为@Controller。

RestController = Controller + ResponseBody。

加RestController,返回是你return中的内容。如是return "success"页面只是显示success

Controller,返回的是return中对应的页面,如return “success” 返回的是success.html

访问页面的时候还出错注释掉一下内容

<thymeleaf.version>3.0.9.RELEASE</thymeleaf.version>
<thymeleaf-layout-dialect.version>2.2.2</thymeleaf-layout-dialect.version>

如果springboot是用1.5的版本的 那时候thymeleaf默认版本是2,需要使用3版本要添加如下版本号:thymeleaf.version 为3.0.9
还有thymeleaf-layout-dialect.version为2.1.1那个配置。 而我的springboot是2.1.1版本的,加了这个就找不到thymeleaf的版本了,
也就找不到thymeleaf了,动态网页就无法显示。所以去掉这两行就可以了

相关文章:

  • 2022-01-04
  • 2021-12-11
  • 2021-12-29
  • 2021-11-30
  • 2021-06-29
  • 2021-12-07
  • 2022-02-04
  • 2022-02-12
猜你喜欢
  • 2021-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-09
  • 2022-12-23
  • 2022-12-23
  • 2021-04-27
相关资源
相似解决方案