文档详情

《RESTful Web Services With Spring MVC》.pdf

发布:2015-10-19约6.09千字共40页下载文档
文本预览下载声明
RESTful Web Services With Spring MVC @DigitalSonic What? Why? How? Richardson Maturity Model Agenda • How to identify Resources • How to use HTTP Verbs • How to design Representations • Miscellaneous • Cache/Version/HATEOAS Resources • Domain Nouns • Collections Composites • Functions • Controllers Samples • Article Comment • http://domain/articles • http://domain/articles/1 • http://domain/articles/1/comments • Web Page • a composite of article and comments • Magazine • a collection of articles Samples • Functions • http://domain/direction?from=shanghaito=hangzhou • Controllers • http://domain/users/smith/address_merge Resource Granularity • Network Efficiency • Size of Representations • Client Convenience URL Mapping in Spring MVC • mvc:annotation-driven/ • @RequestMapping • @PathVariable • @RequestParam • @MatrixVariable Building URI • UriComponents • UriComponentsBuilder • ServletUriComponentsBuilder Better URI • use domains and subdomains to logically group or partition resources • use / to indicate a hierarchical relationship • use , and ; to indicate nonhierarchical elements • use - and _ to improve the readability • use to separate parameters • avoid including file extensions HTTP Verbs Safety Verbs Usage Idempotency GET Y / Y Use GET for safe and idempotent information retrieval. Use this method to let the resource perform a variety of actions on the POST N / N server side such as creating new resources, updating existing
显示全部
相似文档