zoukankan      html  css  js  c++  java
  • 重定向是否可以重定向到post接口

    不能重定向到post接口,但是可以使用RedirectAttributes.addFlashAttribute模拟post效果

    @RequestMapping("/test")
    String test(HttpServletResponse response, RedirectAttributes redirectAttributes) throws IOException {
     //......
     redirectAttributes.addFlashAttribute("message","brx");//重定向过去之后,不会在url栏上显示参数,addAttribute会显示
     redirectAttributes.addFlashAttribute("redirectUrl","456");
     //response.sendRedirect("/toPage"); 推荐使用下面方式,这种参数会有问题
     return "redirect:/toPage";
    
    
     @GetMapping("/toPage") //POST,会提示不支持GET
     public String toPage(@ModelAttribute("message")String message,
                          @ModelAttribute("redirectUrl")String redirectUrl
     //可以在参数增加Model,查看所有请求数据:model.asMap()
    
  • 相关阅读:
    上传文件事件并校验:event.target.files && event.target.files[0]
    深浅拷贝
    Git学习
    Flex弹性布局
    hive
    222
    错误总结
    Redis小结2
    spark小结
    kafka详解
  • 原文地址:https://www.cnblogs.com/brxHqs/p/13645921.html
Copyright © 2011-2022 走看看