springboot-web开发(rest风格支持)
rest风格支持(使用http请求方式动词来标识对资源的操作)
<html><head><meta charset="UTF-8">
</head><body><form action="/user" method="get"><input value="rest-get 提交" type="submit"></form><form action="/user" method="post"><input value="rest-post 提交" type="submit"></form><form action="/user" method="post"><input name="_method" type="hidden" value="DELETE"><input value="rest-delete 提交" type="submit"></form><form action="/user" method="post"><input name="_method" type="hidden" value="PUT"><input value="rest-put_method 提交" type="submit"></form><form action="/user" method="post"><!-- 自定义参数名称 --><input name="_m" type="hidden" value="PUT"><input value="rest-put_m 提交" type="submit"></form>
</body></html>
package com.atchina.boot.controller;import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;@RestController
public class HelloController {@RequestMapping(value = "/user",method = RequestMethod.GET)public String getUser(){return "GET user";}@RequestMapping(value = "/user",method = RequestMethod.POST)public String saveUser(){return "POST user";}@RequestMapping(value = "/user",method = RequestMethod.PUT)public String putUser(){return "PUT user";}@RequestMapping(value = "/user",method = RequestMethod.DELETE)public String deleteUser(){return "DELETE user";}
}
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.filter.HiddenHttpMethodFilter;@Configuration
public class WebConfig {@Beanpublic HiddenHttpMethodFilter hiddenHttpMethodFilter(){HiddenHttpMethodFilter hiddenHttpMethodFilter = new HiddenHttpMethodFilter();// 可以自定义restful风格的methodParamhiddenHttpMethodFilter.setMethodParam("_m");return hiddenHttpMethodFilter;}
}
核心Filter:HiddenHttpMethodFilter 会对 _method的参数进行解析。
我们要想使用系统提供的这个filter,那么这个属性就要我们手工开启。默认是false,不开启。
springboot-web开发(rest风格支持)相关推荐
- html插入flash代码_初学者必备Web开发APP,支持代码补全,一键插入代码,厉害了!...
新手学前端神器,HTML代码补全功能太牛了! 讲过学习后端的许多优秀APP,这次来推荐一下前端用的软件. 前端,包含了HTML+CSS+JavaScript这一整套的流程,缺一不可. 其实,市面上用来 ...
- springboot:web开发-Thymeleaf
1.thymeleaf依赖 <dependency><groupId>org.thymeleaf</groupId><artifactId>thymel ...
- 开发者必备的15 个Web开发工具
Web开发不是一件轻松的任务,开发者需要做很多的事情来确保网站运行正常.高效- 本文介绍15个非常优秀的每个web开发者都应该拥有的工具,列表如下: 1. Firebug Firebug是Firefo ...
- Web 开发常备工具
工欲善其事,必先利其器.如今 Web 开发标准越来越高,Web 开发者也在不断寻找途径提升自己的技能.为使大家的开发工作更顺利进行,本文整理了 10+ 款比较优秀的 Web 开发工具,希望对你有帮助. ...
- 网页开发工具有哪些?——开发者必备的15个Web开发工具
<!DOCTYPE html> <html lang="en"> <head><meta charset="UTF-8" ...
- Web开发技术的历史发展简介
讨论Web开发技术的历史,当然要先说说Web的起源.众所周知,Web这个Internet上最热门的应用架构是由Tim Berners-Lee发明的.Web的前身是1980年Tim Berners-Le ...
- 15 个开发者必备的Web开发工具!
Web开发不是一件轻松的任务,开发者需要做很多的事情来确保网站运行正常.高效... 本文介绍15个非常优秀的每个web开发者都应该拥有的工具,列表如下: 1. Firebug Firebug是Fire ...
- SpringBoot的Web开发支持【超详细【一篇搞定】果断收藏系列】
SpringBoot的Web开发支持 常用的服务器配置 使用Jetty服务器替换Tomcat 排除Tomcat的启动器,引入Jetty application.yml 编写入口程序 编写Control ...
- SpringBoot 之 Web开发
2.Web开发 2.1.SpringMVC自动化配置概述 Spring Boot provides auto-configuration for Spring MVC that works well ...
最新文章
- matplotlib可视化基本散点图、在图像指定区域绘制方框并进行自定义色彩填充(Draw Rectangle filled with color)
- Android自定义动态壁纸,Android自定义动态壁纸开发详解
- asp.net core 系列之Performance的 Response compression(响应压缩)
- JDK环境变量配置(一次性成功)
- Android studio的Activity详解
- 超详细的jenkins持续集成工作原理、功能、部署方式等介绍
- 关于mysql_free_result和mysql_close的解惑
- 优雅的实现微信分享/支付,组件化
- 局域网带宽控制解决方案-P2P终结者使用详解
- libusb 串口 android,libusb 根据设备的serialnumber来打开
- matlab显示 图注,Matlab图例注记乱码(2019a)
- 201671030119 词频统计软件项目报告
- android 小米盒子开发,接小米盒子Android SDK
- CF 815C 树形背包
- WindowsWord 常用快捷键
- C++查询文本中所有单词出现的频率,并且根据出现次数由多到少依次排列。
- nas修改启动盘sn和mac
- python中type dtype astype 的用法
- Excel导出模板加数据时,下拉框丢失解决方案
- Ubuntu 22 安装go-ethereum