一、controller
@Controller
@RequestMapping("demo")
public class DemoController {
@GetMapping("")
@ResponseBody
public String find() {
return "get请求";
}
@DeleteMapping("")
@ResponseBody
public String delete() {
return "delete请求";
}
@PutMapping("")
@ResponseBody
public String put() {
return "put请求";
}
@PostMapping("")
@ResponseBody
public String post() {
return "post请求";
}
}
二、配置文件
spring:
resources:
static-locations: [classpath:/hello/]
# add-mappings: false #禁用所有静态资源规则
# cache:
# period: 11000 #
mvc:
hiddenmethod:
filter:
enabled: true #开启页面表单的rest功能
三、html页面
<h2>hello测试,欢迎</h2>
<form action="/demo" method="get">
<input type="submit" value="get提交">
</form>
<form action="/demo" method="post">
<input type="submit" value="post提交">
</form>
<form action="/demo" method="post">
<input name="_method" type="hidden" value="put"/>
<input type="submit" value="put提交">
</form>
<form action="/demo" method="post">
<input name="_method" type="hidden" value="delete"/>
<input type="submit" value="delete提交">
</form>
四、示例
详细文档:https://www.yuque.com/atguigu/springboot/vgzmgh
雷丰阳2021版SpringBoot2零基础入门springboot全套完整版(spring boot2)
雷丰阳2021版SpringBoot2零基础入门springboot全套完整版(spring boot2)
雷丰阳2021版SpringBoot2零基础入门springboot全套完整版(spring boot2)
雷丰阳2021版SpringBoot2零基础入门springboot全套完整版(spring boot2)