From the course: Spring: Spring MVC

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Use @Controller and @ResponseBody

Use @Controller and @ResponseBody

From the course: Spring: Spring MVC

Start my 1-month free trial

Use @Controller and @ResponseBody

- [Instructor] Now let us create simple RESTful services with a H plus spring MVC application. Let's create a controller, which uses two annotations, @controller, and @responsebody. Let's go back to the IDE, and on com.testwork H plus, I'm going to right click and create a new package first, which will be called REST controllers. I'm deliberately trying to keep this in a separate package so that when you refer the code, you have a clear distinction of which one was a REST controller and which one was an MVC controller. Under this, let's create a class. Let's call this products best controller. And let's designate this as controller quickly and down there let's provide a get mapping. Now there's a convention that your RESTful services generally follow when you try to define the URL pattern. So let's say this is called H plus/rest/products. Something like this. Alternatively, you could also use request…

Contents