1

The point is, how exactly to identify a Spring MVC implementing RESTful web services? Assuming use of Spring 3.x, use of which all annotations in the project will indicate that the project implements RESTful web services?

2 Answers 2

2

If the controller is annotated with @RestController or the @RequestMapping methods has @ResponseBody on return type then those are REST Service.

Sign up to request clarification or add additional context in comments.

Comments

1

Assuming you are using Spring 3.x

All the Spring MVC components has to use the common @Controller annotation to mark that as the controller servlet. In short controller servlet should be annotated with @Controller

When you implement a RESTful web services in Spring 3.x, the response would be always sent with the response body. In short Controllers which implement a REST API should be annotated with @Controller+@ResponseBody

Additional information

Spring 4.0 has provided a specialized version of controller- @RestController.

@RestController is a stereotype annotation that combines @ResponseBody and @Controller. @RestController annotation itself annotated with @Controller and @ResponseBody.

 @Target(value=TYPE)
 @Retention(value=RUNTIME)
 @Documented
 @Controller
 @ResponseBody
public @interface RestController

See the Spring docs for more information

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.