RedirectAttributes详解

RedirectAttributes  的两个方式的获取总结:
1:addFlashAttribute
Java code
?
1
2
3
4
5
6
7
8
9
10
11
     
    @RequestMapping (value= "hello" )
     public  String test(RedirectAttributes ra){
         ra.addFlashAttribute( "test" "test" );
         return  "redirect:/test" ;
     }
     @RequestMapping (value= "test" )
     public  String test( @ModelAttribute ( "test" )String test){
         System.out.println(test);
         return  "redirect:/hello" ;
     }

2:addAttribute
Java code
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
@RequestMapping (value= "hello" )
public  String test(RedirectAttributes ra){
     ra.addAttribute( "test" "test" );
     return  "redirect:/test" ;
}
@RequestMapping (value= "test" )
public  String test(HttpServletRequest request ){
     String test = request.getParameter( "test" );
     
     System.out.println(test);
     return  "redirect:/hello" ;
}

猜你喜欢

转载自blog.csdn.net/ly199108171231/article/details/53612336