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.

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

@RestController

 

No equivalent annotation 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 annotation in JAX-RS. Method parameters that correspond to the body of the request are handled in JAX-RS without requiring any annotation.

@RestControllerAdvice

 

No equivalent annotation in JAX-RS.

@ResponseStatus

 

No equivalent annotation in JAX-RS.

@ExceptionHandler

 

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

Back to top
Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust. Explore our recent updates.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Theme

© 2025 Red Hat