1. 程式人生 > >SpringBoot入門07-Thymeleaf中顯示ajax請求到的資料

SpringBoot入門07-Thymeleaf中顯示ajax請求到的資料

Thymeleaf中顯示ajax請求所需依賴

<!--所需依賴-->
<
dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> <!--去除HTML 嚴格規範-->
<dependency>
    <groupId>net.sourceforge.nekohtml</
groupId> <artifactId>nekohtml</artifactId> <version>1.9.22</version> </dependency>

 

控制器中支援ajax請求的註解@ResponseBody

springboot與SSM中的控制器支援ajax請求方法沒有區別

@ResponseBody寫在控制器的方法上,只表示本方法適合ajax請求

@ResponseBody寫在控制器類上,表示該類中所有方法適合ajax請求

 

怎樣在Thymeleaf中顯示ajax請求到的資料