我是靠谱客的博主 精明小兔子,这篇文章主要介绍Spring Boot笔记-使用RedirectAttributes重定向后也可以显示填写的信息,现在分享给大家,希望可以做个参考。

这里是这样的,提交表单后,重定向,在以前的函数里面设置了一些前端的信息。

重定向后,还能显示出来。

 

最后指定的函数:

    @GetMapping("/")
    public String getIndex(){

        return "index";
    }

调用的函数:

    @PostMapping("/check")
    public String checkCipherAndSendEmail(@RequestParam("cipherString") String cipherString,
                                          @RequestParam("emailString") String emailString,
                                          @RequestParam("urlString") String urlString,
                                          @RequestParam("Ticket") String ticket,
                                          @RequestParam("RandStr") String randStr,
                                          HttpServletRequest request,
                                          RedirectAttributes redirectAttributes){

        //TODO something
        //业务代码

        redirectAttributes.addFlashAttribute("msg", "提示:文件下载成功,正发往指定邮箱");
        return "redirect:/";
    }

 

最后

以上就是精明小兔子最近收集整理的关于Spring Boot笔记-使用RedirectAttributes重定向后也可以显示填写的信息的全部内容,更多相关Spring内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(115)

评论列表共有 0 条评论

立即
投稿
返回
顶部