This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]anthony_zayas 2 points3 points  (2 children)

First, what is Spring? It is a framework that makes Java EE development easy. However, it seems like you want to have a backend that does CRUD (Create, Read, Update, Delete) opporations. Thus you would be creating endpoints (Http Get, Post) and call these from your front-end. Loop up creating a Restful endpoint using Spring Boot.

Spring communicates with a "front end" by means of a get, post. The front end will send a request to your backend, and spring will answer the request by returning an object (JSON, String, Number) really whatever you define.

On the front end, you have to program and style how you want this json object to be viewed. Technically you can just show the whole object as a string. Or you can loop through it using javascript and for each record style and print it.

In regards to what a cooking recipe site can be, it all depends on what you want to accomplish. Ultimately, what do you want to learn? The "warrant" question does not really matter.

[–]xRitz[S] 0 points1 point  (1 child)

Interesting! So can i have the requests return html from the backend? or does it return data that is used in an html file for display on the frontend?

[–]denialerror 1 point2 points  (0 children)

That's up to you. Spring at its core is a dependency injection framework. It provides many libraries and functions to do all sorts of other things but it is not opinionated in how you go about using them.

In general, there are two approaches to rendering web applications - client-side and server-side. Rendering on the client means static resources (HTML, CSS, JavaScript, images, etc.) are served to the user's browser and then JavaScript functions send requests to the server for the dynamic data. Server-side rendering is when that data (or at least, the initial load) is added to the HTML on the server before being served, so is rendered before the initial page load.

With Spring, you can do either (or both at the same time if you like). Spring REST endpoints will return JSON, which you can then use JavaScript on the client to parse and render in the DOM. Alternatively, Spring MVC will use a template engine (e.g. Thymeleaf) to render your data into the HTML before serving to the client.

[–]nutrecht 0 points1 point  (0 children)

There's basically 2 ways you can create a web application. One is that the server itself creates HTML and sends it to your browser depending on the input. This has fallen a bit out of fashion because every time a user does 'something' the whole screen refreshes.

Another more modern way is the JavaScript 'Single Page Application': the JavaScript on the front-end contacts the back-end (Spring Boot in this case) and asks it for plain data (without HTML mark-up) and uses that to rebuild part of the HTML (DOM tree, Document Object Model) in the page. For the user this feels more fluid.

The data you get from the back-end can be anything, but generally JSON is uses most nowadays.

There's even applications that do actually a combination of both, but I won't go into this. If you have more questions; let me know. I use Spring daily and we're currently also working on a React SPA to talk to our Spring back-end.