重定向用户和POST参数

时间:2019-06-14 21:43:05

标签: java spring spring-boot

我想在打开页面和POST参数时重定向用户。我尝试过:

@PostMapping(value = "/redirect/{token}"})
  public ModelAndView handleRedirectMessage(@PathVariable("token") String token,
          @RequestBody Transaction transaction, HttpServletRequest request) throws Exception {

        String post_param = "some_payload";
        return new ModelAndView("redirect:" + url); 
  }

是否可以重定向用户并发布一些参数?

1 个答案:

答案 0 :(得分:0)

例如,您有

@GetMapping("/sample_request_mapping_path")
public ModelAndView something() {
    //...
}

修改为

@PostMapping(value = "/foo"})
public ModelAndView handleRedirectMessage(@PathVariable("token") String token, @RequestBody Transaction transaction, HttpServletRequest request) throws Exception {
    String post_param = "some_payload";
    return "redirect:/sample_request_mapping_path"; 
}
相关问题