It is necessary to create a separate project for java spring boot and frontend and backend. I am doing the frontend, with spring boot thymeleaf (html css bootsrap js). I made the endpoint coming from the backend with Postmande mock server. But I am giving the url manually in the controller. Is there a different way to do this? Or what should happen?
`@Controller
public class StudentController {
private final RestTemplate restTemplate;
public StudentController(RestTemplate restTemplate) {
this.restTemplate = restTemplate;
}
@GetMapping("/")
public String getStudents(Model model) {
String url = "https://....mock.pstmn.io/getStudentList";
Student[] students = restTemplate.getForObject(url, Student[].class);
model.addAttribute("students", students);
return "index";
}
}`
What I want to do is to use the endpoint frontend coming from the backend.
javalover4ever is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.