I want to go with an object to another page and show it there
ViewControllers
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/songs")
.setViewName("/song.html");
registry.addViewController("/")
.setViewName("/index.html");
}
Controller
@RestController
@RequestMapping("/songs")
public class SongController {
@RequestMapping("/getSong")
public Track getSong(String id){
System.out.println("Song id " + id);
Optional<Track> byId = trackService.findById(Integer.parseInt(id));
if(!byId.isPresent()) throw new NullPointerException();
return byId.get();
}
and JQuery
$.ajax({
type: "POST",
url: "/songs/getSong",
data: {
id: songId
}
});
it calls method but i dont go to another page) what should i do to reach another page with this object or with id without using jsp or thymeleaf?