Chapter 9. Overview of Spring Web annotations and their JAX-RS equivalents

The following table shows how Spring Web annotations can be converted to JAX-RS annotations.

Table 9.1. Spring Web annotations and their JAX-RS equivalents

SpringJAX-RSNotes

@RestController

 

There is no equivalent in JAX-RS. Annotating a class with @Path suffices.

@RequestMapping(path="/api")

@Path("/api")

 

@RequestMapping(consumes="application/json")

@Consumes("application/json")

 

@RequestMapping(produces="application/json")

@Produces("application/json")

 

@RequestParam

@QueryParam

 

@PathVariable

@PathParam

 

@RequestBody

 

No equivalent in JAX-RS. Method parameters corresponding to the body of the request are handled in JAX-RS without requiring any annotation.

@RestControllerAdvice

 

No equivalent in JAX-RS.

@ResponseStatus

 

No equivalent in JAX-RS.

@ExceptionHandler

 

No equivalent annotation in JAX-RS. Exceptions are handled by implementing javax.ws.rs.ext.ExceptionMapper.