Java EE notebook
  • Introduction
  • /web-customer-tracker
  • Web Service
  • AOP
  • Web Server2(Spring REST)
  • Security
  • Json
  • Web Server VS Application Server VS Web Containers
  • different between Servlet & JSP2
  • DI
  • 0
  • 1annotation inversion of control, bean scope
  • 2 annotation dependency injection
  • 3 annotation bean scope, java code config
  • 4 Spring MVC
  • rest web services
  • Spring-Hibernate0
  • Spring-Hibernate1
  • @ManyToMany
  • spring mvc work flow
  • Spring Security
  • JWT
  • @Autowired
  • Jersey REST Service
  • Spring Bean
Powered by GitBook
On this page
  • Creating a REST Web Service With Java and Spring
  • 1. HTTP verbs
  • 2. org.springframework.hateoas.

Was this helpful?

Web Server2(Spring REST)

PreviousAOPNextSecurity

Last updated 5 years ago

Was this helpful?

Creating a REST Web Service With Java and Spring

1. HTTP verbs

HTTP VERB

URL

DESCRIPTION

GET

/order

Obtains the list of all orders currently created in the system. If the list is successfully obtained, the list of existing orders is returned, along with an HTTP200(OK) status.

POST

/order

Creates a new order. This request should carry a request body that includes the data that should be associated with the newly created order. If the order is created, an HTTP201(Created) status is returned along with the newly created order in the response body.

GET

/order/{id}

Obtains the order associated with the given ID. If no order exists, an HTTP404(Not Found) status is returned. If the order can be found, an HTTP200status is returned and the response body contains the information associated with the order.

PUT

/order/{id}

Updates an existing order. If no order with the given ID can be found, an HTTP404status is returned. If an order exists with the given ID and the request body contains valid updates to the order, the order is updated and the updated order is returned in the response body, along with an HTTP200status.

DELETE

/order/{id}

Deletes an order with the given ID. If no order exists, an HTTP404status is returned. If the order exists, it is deleted, and an HTTP204(No Content) status is returned.

2. org.springframework.hateoas.

Spring HATEOAS provides some APIs to ease creating REST representations that follow the HATEOAS principle when working with Spring and especially Spring MVC. The core problem it tries to address is link creation and representation assembly.

Features

  • Model classes for link, resource representation models

  • Link builder API to create links pointing to Spring MVC controller methods

  • Support for hypermedia formats like HAL

https://dzone.com/articles/creating-a-rest-api-with-java-and-spring