RESTful for URL simplification

Source: Internet
Author: User
Tags representational state transfer

Rest is an English representational state transfer (representational state transition) or representational status transfer, which is an architectural style of Web services. Use widely popular standards and protocols such as http,uri,xml,json,html; lightweight, cross-platform, cross-language architecture design; it is a design style, not a standard, is a kind of thought.

The main principles of the rest architecture:
Everything on the network is abstracted as a resource;
Each resource has a unique resource identifier;
The same resource has multiple manifestations (xml,json, etc.);
Various operations on resources do not alter resource identifiers;
All operations are stateless;
A restful approach can be described as an architectural method that conforms to the rest principle.

What is restful? The corresponding Chinese is restful; RESTful web service is a common rest application that adheres to restful web services, and RESTful Web services is a kind of roa (the resource-oriented Architecture) (Resource-oriented architecture).

Why is there a restful?
Before the restful operation:
HTTP://127.0.0.1/USER/QUERY/1 GET query user data based on user ID
Http://127.0.0.1/user/save POST New User
Http://127.0.0.1/user/update POST Modifying user information
Http://127.0.0.1/user/delete get/post Delete User information

RESTful usage:
HTTP://127.0.0.1/USER/1 GET query user data based on user ID
Http://127.0.0.1/user POST New User
Http://127.0.0.1/user PUT Modify user Information
Http://127.0.0.1/user Delete User Information

  

SPRINGMVC's original ecosystem supports the rest-style architecture design, which involves annotations:

[Email protected] [Email protected] [Email protected]

Front-end access page index.jsp:

<%@ page contenttype= "Text/html;charset=utf-8" language= "java"%>

Background controller TestController2. Java:

Package Com.itszt.controller;import Org.springframework.stereotype.controller;import Org.springframework.web.bind.annotation.pathvariable;import org.springframework.web.bind.annotation.requestmapping;/** * Test restful */@RequestMapping ("Test2") @ Controllerpublic class TestController2 {    @RequestMapping ("Delete/{delid}/{deltitle}") Public    String Delete ( @PathVariable (name = "Delid") string delid, @PathVariable (name = "Deltitle") string deltitle) {        System.out.println (" Delid = ["+ Delid +"], Deltitle = ["+ Deltitle +"] ");        return "result";    

RESTful for URL simplification

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.