0
How can we connect java endpoint to a html button?
Coding has to be done in java spring boot and the gui using html
2 Answers
+ 2
The short answer is AJAX.
The click scenario would eventually work like this:
1. User clicks button
2. A JavaScript function handles the click event.
3. That JavaScript function creates and sends an HTTP request to your endpoint.
4. Your endpoint responds and JavaScript will take desired action on the response. This could include updating the document to tell the user that something was saved.
You'll need to know what URL to hit, what HTTP method to use(GET, POST, PUT, DELETE)... and possibly what extra data to send in your request so your API works.
If you end up using jQuery, see:
https://api.jquery.com/jquery.ajax/
The standard but still somewhat new fetch function could help:
https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
I haven't used Java Spring Boot but I'll assume you know how to create a working end point with it.