spring-boot Controller的使用
程序员文章站
2022-03-11 09:00:42
...
Controller结合模板使用:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
在resource文件下建立templates目录
package com.example.demo.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
public class HeController {
@RequestMapping(value = "/cxx",method = RequestMethod.GET)
public String gethtml(){
return "index";
}
}