SpringBoot中使用Thymeleaf模板引擎无法实现return转化怎么办???

本文介绍了在SpringBoot项目中使用Thymeleaf模板引擎时,通过@Controller注解的方法返回HTML页面遇到的问题。强调了不能使用@RestController,而应该使用@Controller,同时提到了pom.xml配置,Controller层代码,HTML文件的位置和application.properties的配置。
摘要由CSDN通过智能技术生成

我们知道在SpringBoot中可以在@Controller类下的 @RequestMapping("")下的方法中根据return可以跳转到resources/templates下的html页面。但是你这里要注意一点必须是使用@Controller的Controller类,**绝对不可以使用@RestController,使用@RestController是无效的。 **
1 pom文件

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.3.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.zxf</groupId>
    <artifactId>spring_boot_0828</artifactId>
    <version>
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值