# Spring-REST **Repository Path**: shenzhanwang/Spring-REST ## Basic Information - **Project Name**: Spring-REST - **Description**: Spring boot发布与调用REST风格的API - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 126 - **Forks**: 48 - **Created**: 2017-02-09 - **Last Updated**: 2025-05-21 ## Categories & Tags **Categories**: restful **Tags**: None ## README # Spring-REST 如果说Web Service是一种特殊的RPC,那么REST Service又是一种特殊的Web Service,目前已成为分布式通信的重要手段。本项目基于Spring框架,完成REST(表现层状态转移)风格的接口的发布(Server)与接收(Client)。特性如下: Server端: 1.基于SpringMVC的@RequestMapping的属性method配置GET,POST,DELETE,PUT四种HTTP请求,对应于CRUD的四种操作; 2.前端页面发送四种HTTP请求,可通过Jquery的ajax方法完成; 3.前后台通过json通信,对于POST和PUT请求,ajax需要提交json字符串作为数据,后台用@RequestBody接收json转为java对象; 5. 需要用mysql建立表格actor持久化数据: CREATE TABLE `actor` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(45) DEFAULT NULL, `age` int(11) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=22 DEFAULT CHARSET=utf8; 6.Server端入口: http://localhost:8081/rest Cilent端: 1.客户端使用Spring的RestTemplate的API发送GET,POST,DELETE,PUT请求,底层是通过HttpClient实现远程调用; 2.注意POST和PUT方法,发送的请求包含了HTTP头设置,否则容易出415的错误; 3.前端页面提交json数据到后台的模板为: $.ajax({ url : "actors", type : "POST/DELETE/PUT", data : JSON.stringify(json), //转JSON字符串 dataType: 'json', contentType:'application/json;charset=UTF-8', //contentType很重要 success : function(result) { }); 如果是GET请求,直接$.get(...)即可; 4.Client端入口: http://localhost:8080/rest 效果图:  ### 好书推荐  |购买地址| |--| || ### 专利文章 | | 标题 | 技术领域 | |---|----|------| | 1 | [一种基于微服务架构的车联网大数据分析系统](https://mp.weixin.qq.com/s?__biz=Mzg5MjY3OTk0OQ==&mid=2247484096&idx=1&sn=11677bc50cd18e448135319394238e80&chksm=c03b20a2f74ca9b41c7d1c1e60e1407e1530a98b86498822f387da26e551826f8136663b45a0#rd) | 微服务| | 2 | [一种流式数据场景下Elasticsearch索引的自动化扩容方法](https://mp.weixin.qq.com/s?__biz=Mzg5MjY3OTk0OQ==&mid=2247484167&idx=1&sn=94587b5e196bbda2d6cc4b976b03d0c7&chksm=c03b2165f74ca873b77380a23c4e06b71adf6ffc40634440f467fb71c20aa4cc2fe72a5d65a9#rd) | 搜索引擎 | | 3 | [大数据钻取分析方法、装置、设备及存储介质](https://mp.weixin.qq.com/s?__biz=Mzg5MjY3OTk0OQ==&mid=2247484385&idx=1&sn=6fe4a4ac34badd91db39b4cc042a3f18&chksm=c03b2183f74ca89508333f3d5c8330aa32248eda86e4cf7657a5a293e1bf9d49888fe78b1072#rd) | 大数据分析 | | 4 | [一种基于工作流引擎的自动化办公方法和系统](https://mp.weixin.qq.com/s?__biz=Mzg5MjY3OTk0OQ==&mid=2247484895&idx=1&sn=1094f0b9abef603e8126dea68db75cca&chksm=c03b27bdf74caeab50d56ac110b9ab0d36bc9b9069e311083a5c4295ab03ee4b0595a00a3ba2#rd) | 工作流引擎 | | 5 | [一种低延迟高性能实时数据仓库搭建的方法和系统](https://mp.weixin.qq.com/s?__biz=Mzg5MjY3OTk0OQ==&mid=2247485672&idx=1&sn=ef9b05e32790091f6e984d14624d9560&chksm=c03b2a8af74ca39c24c9354279036148cd72315f22d06ab63649808d70161d8b4f53d38cc5fb&scene=178&cur_album_id=3268880015212085251#rd) | 实时数仓 | | 6 | [一种基于数据治理的大数据中台架构系统](https://mp.weixin.qq.com/s?__biz=Mzg5MjY3OTk0OQ==&mid=2247485875&idx=1&sn=db58f023c92ca01cc1902e7bea806a48&chksm=c03b2bd1f74ca2c7b45f993386f443718a99a378a51d9be827c2e45b326c549a868089fbdd31&scene=178&cur_album_id=3268880015212085251#rd) | 数据中台 | ### 视频教程 |
| |--| | | ### 附录:中央技术储备仓库(Central Technique Reserve Repository) 1. [Spring boot整合Mybatis实现增删改查(支持多数据源)](https://gitee.com/shenzhanwang/SSM) 2. [Spring,SpringMVC和Hibernate的整合实现增删改查](https://gitee.com/shenzhanwang/SSH) 3. [Spring boot整合activiti工作流引擎实现OA开发](https://gitee.com/shenzhanwang/Spring-activiti) 4. [Ruoyi-boot集成工作流引擎Flowable实例](https://gitee.com/shenzhanwang/Ruoyi-flowable) 5. [Spring发布与调用REST风格的WebService](https://gitee.com/shenzhanwang/Spring-REST) 6. [Spring boot整合Axis调用SOAP风格的web服务](https://gitee.com/shenzhanwang/Spring-axis) 7. [Spring boot整合Apache Shiro实现RBAC权限控制](https://gitee.com/shenzhanwang/Spring-shiro) 8. [使用Spring security实现RBAC权限控制](https://gitee.com/shenzhanwang/spring-security-demo) 9. [Spring boot整合mongoDB文档数据库实现增删改查](https://gitee.com/shenzhanwang/Spring-mongoDB) 10. [Spring连接Redis实现缓存](https://gitee.com/shenzhanwang/Spring-redis) 11. [Spring连接图存数据库Neo4j实现增删改查](https://gitee.com/shenzhanwang/Spring-neo4j) 12. Spring boot整合列存数据库hbase实现增删改查 13. [Spring平台整合消息队列ActiveMQ实现发布订阅、生产者消费者模型(JMS)](https://gitee.com/shenzhanwang/Spring-activeMQ) 14. [Spring boot整合消息队列RabbitMQ实现四种消息模式(AMQP)](https://gitee.com/shenzhanwang/Spring-rabbitMQ) 15. Spring boot整合kafka 2.1.0实现大数据消息管道 16. [Spring boot整合websocket实现即时通讯](https://gitee.com/shenzhanwang/Spring-websocket) 17. [Spring security整合oauth2实现token认证](https://gitee.com/shenzhanwang/Spring-security-oauth2) 18. [Spring boot整合MinIO客户端实现文件管理](https://gitee.com/shenzhanwang/Spring-minio) 19. 23种设计模式,源码、注释、使用场景 20. [使用ETL工具Kettle的实例](https://gitee.com/shenzhanwang/Kettle-demo) 21. Git指南和分支管理策略 22. 使用Apache Doris搭建实时数仓 23. [zookeeper原理、架构、使用场景和可视化](https://gitee.com/shenzhanwang/zookeeper-practice) 24. Spring boot整合Apache dubbo v2.7.5实现分布式服务治理(SOA架构)  25. 使用Spring Cloud Alibaba v2.2.7实现微服务架构(MSA架构) 26. 使用Apache Paimon搭建流式数据湖 27. 使用kubernetes+docker+gitlab+spring cloud实现云服务的编排、持续集成和动态扩容 28. 使用Spark进行分布式计算 29. 使用Flink实现流批一体化的分布式计算 30. 搭建高可用nginx集群和Tomcat负载均衡 31. 使用mycat实现Mysql数据库的主从复制、读写分离、分表分库、负载均衡和高可用 32. [《Elasticsearch数据搜索与分析实战》源码](https://gitee.com/shenzhanwang/Spring-elastic_search)  33. 基于可靠消息最终一致性实现分布式事务(activeMQ) 34. Spring boot dubbo整合seata实现分布式事务 35. Spring cloud alibaba 整合seata实现分布式事务  36. 并发控制:数据库锁机制和事务隔离级别的实现 37. 并发控制:使用redission实现分布式锁 38. 并发控制:使用zookeeper实现分布式锁 39. 并发控制:Java多线程编程实例 40. 并发控制:使用netty实现高性能NIO通信 ### 关注微信公众号获取更多技术文章和源码 