posted 7 years ago
Hello everybody,
I started studying enterprise development a lot of time ago and I finished up with using Spring Boot for the application and Thymeleaf + Boostrap for the html templates.
I also used the book Spring Boot in Action (that I found in this forum) to learn the basics. So far I developed an application with authentication, and a users management (CRUD operations) based on a MySql database.
According to the tutorial in the book, the controller handles the request returning the name of the html file to load (plus a model with one or more attributes that are the data to be displayed).
Then a big doubt came to my mind... In the beginning I wanted to develop a RESTful application, but when I replace the @Controller annotation with @RestController I realized that my application does not satisfy REST specification at all. I dove into Google immediately, trying to find an answer, and here's what I understood: a RESTful server application is developed to serve a client application rather than be accessed by a browser (which, for example, only supports the GET and POST methods, and has no PUT, PATCH, DELETE,...). When developing an enterprise applicatiom, it seems there are two completely different approaches: on one side we have a RESTful server application with a client application, on the other we have a so-called MVC web application, which rely on a view technology, and a standard browser (Chrome, Firefox,...).
This is confirmed by the fact that, for example, Thymeleaf use the model to get data and display them in a web page, while a RESTful application returns these data in a different format (e.g. json).
I'm sorry for the post length and also for my bad English, I would like to know your opinion about my ideas and get some suggestions, for example, is it possible to implement a RESTful application that can be used by a browser (which means, create html templates that understand and display data in REST format)?
Thank you