1:addFlashAttribute
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
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"
;
}
|