I have a controller which extend the class ControllerBase.
Declare a SessionAttributes by annontation
A method declarationCode:@Controller @SessionAttributes(value = { "account", "action", "group", "groups", "groupUserMap", "notGroupUserMap" }) @SuppressWarnings("unchecked") public class GroupController extends ControllerBase {
At the end of the above method, the following attribute are put to model.Code:@RequestMapping(value = "/group/list", method = RequestMethod.GET) public String list(@RequestParam(required = false) String[] messages, @ModelAttribute Account account, Model model, Locale locale) {
Another method in the same controller.Code:model.addAttribute("groups", groups); model.addAttribute("defaultGroup", defaultgroup);
At the end of this method, it return to another view and need to access the previous defined model attribute "group" and "defaultgroup". But I found that the attribute are not there anymore. I put some debut code inside the method prepareAdd, iterate the model map and print out the entry set, and found that the group and defaultgroup entry are already cleared.Code:public String prepareAdd(@RequestParam(required = false) String groupName, @ModelAttribute Account account, Model model, Locale locale) throws IOException {
I really don't understand why the SessionAttributes is not working. Anything I do wrong? Any hint how to use the SessionAttributes correctly?
The software is written by others, and I'm very new to Spring, your advice would be very helpful .![]()


Reply With Quote
