SpringBoot question: After reading the stored-value less than RedirectAttributes

First, check whether the Controller is above or @Controller @RestController (difference between the two self-Baidu)

Secondly, as follows

    @GetMapping ( "/ the redirect") 
    public String the redirect (RedirectAttributes redirectAttributes) 
    { 
        redirectAttributes.addFlashAttribute ( "Test",. 1); 
        return "the redirect: / Show"; 
    } 

    @GetMapping ( "/ Show") 
    @ResponseBody 
    // must Add @ModelAttribute label, no side will not read the value 
    // and must specify the variable name, and do not automatically match the 
    public the Map <String, Object> Show (@ModelAttribute ( "the Test") int the Test) 
    { 
        the Map <String, Object> = new new a ModelMap the HashMap <> (); 
        modelMap.put ( "String", Test); 
        return a ModelMap; 
    }

  

Guess you like

Origin www.cnblogs.com/bigcabbage/p/10988896.html