0

I am trying to make our apis available as restful service.

Defined a controller with @Controller and inside defined a method as follows

@RequestMapping(value="/empDetails/{empName}", method=RequestMethod.GET)
public void getUserData(@PathVariable("empName") String empName, Model model) {
}

Does the above makes the api as Restful ???

In Simple just giving annotation makes the method as Restful API???

Thanks.

Kathir
  • 23
  • 1
  • 5

1 Answers1

1

You make it RESTFul API by returning an object, usually a JSON, rather than using MVC.

For your own convenience you could use @RestController instead of @Controller. You can learn about the differences here.

Just an advice, depending on your snippet, when you use GET methods, return a JSON rather than void.

You can see a spring REST example (ignore the spring boot part).

And you could also see a spring MVC example

I hope the differences will give you a clear point of view

Community
  • 1
  • 1
Jonathan La'Fey
  • 542
  • 5
  • 13