M
M
mirus362016-07-06 15:18:03
Angular
mirus36, 2016-07-06 15:18:03

Angular 2 + Spring is it good to do everything on REST controllers?

Good day. I am learning Spring and Angular 2. I am learning by writing a web application using these frameworks. The application is a control panel for some server that implements business logic. Access to all sections of the application is planned to be made secure, for which it is planned to use spring security.
Actually the question itself: as I see it, angular does not need jsp at all on the server side, it only needs to pull html from the server for templates, will it be good practice in springs to do everything through rest controllers returning static html? And already on them to hang security guards?
The question arose, because before that in my practice everything was done on jsp, and I did not see examples of rest controllers returning html.
If you know where to get ready-made application frameworks, I will be grateful.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander Kosarev, 2016-07-07
@mirus36

Actually the question itself: as I see it, angular does not need jsp at all on the server side, it only needs to pull html from the server for templates, will it be good practice in springs to do everything through rest controllers returning static html? And already on them to hang security guards?

This would be very bad practice. Rest controllers should return only DATA in a format convenient for the client (JSON, XML, YAML, etc.), otherwise it is no longer REST.
And "hang security" on static resources does not make sense. Except when there is protected data in these resources, but the presence of such data in static resources, in principle, contradicts security.
And they don’t exist in nature, a Rest controller that returns a view is by definition not REST.
In my opinion, HTML views should be stored separately and served using a servlet container/web server. Ideally, all static should be in another project at all, since a set of REST services is a server side, and an HTML application is a client side.

S
Sergey, 2016-07-06
Protko @Fesor

it only needs to pull html from the server for templates

If you use only inline templates, then this is not necessary in principle. An Angular application is self-sufficient, the API is used as a data source simply. Like a database in spring applications.
This makes little sense. There is a very small percentage of tasks where there can be some profit from this, but in general it is better to do so that the angular application does not depend on spring or java at all.

M
Maxim Vasiliev, 2016-07-06
@qmax

HTML templates can be served generally as static content, through nginx or whatever you have there.
It is unlikely that they implement double templating, or contain nda information.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question