Jquery 如何转到另一个包含数据的页面

Jquery 如何转到另一个包含数据的页面,jquery,spring,rest,model-view-controller,Jquery,Spring,Rest,Model View Controller,我想将一个对象转到另一个页面并在那里显示它 视图控制器 @Override public void addViewControllers(ViewControllerRegistry registry) { registry.addViewController("/songs") .setViewName("/song.html"); registry.addViewController("/")

我想将一个对象转到另一个页面并在那里显示它

视图控制器

    @Override
public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/songs")
                .setViewName("/song.html");
        registry.addViewController("/")
                .setViewName("/index.html");
}
控制器

@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();
}
它调用方法,但我不转到另一页) 我应该如何使用此对象或id访问另一个页面
不使用jsp或thymeleaf?

如果希望将请求的结果传输到另一个页面,请不要使用ajax。使用ajax的主要目的是避免页面传输。使用普通表单提交。['code'](window.location=“/song?id=“+songId;)我尝试过这样做,它确实会更改页面,但我无法获取id,它是空的(如果端点映射没有显示它必须是POST请求,那么这可能会起作用。如果songId为null,那么您会遇到与此相关的另一个问题,这与您迄今为止提供的逻辑无法识别。它仅在controllers方法中为null,在brouser中为数字。@Taplar它必须是POST请求结果。)与GET相同,您必须为请求映射配置参数的来源
  $.ajax({
            type: "POST",
            url: "/songs/getSong",
            data: {
                id: songId
            }
        });