Announcement Announcement Module
Collapse
No announcement yet.
Loading ModelMap from HTTP query parameters Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Loading ModelMap from HTTP query parameters

    From spring doc about redirecting:

    All model attributes are exposed as HTTP query parameters
    After redirect, how can I add attributes from HTTP query parameters to ModelMap? Can I avoid adding attributes manually ?

    Code:
    @Controller
    class SomeController {
    
        @RequestMapping(value = "/test_path", method = RequestMethod.POST)
        public String doPost(ModelMap modelMap) {
            modelMap.put("message", "OK");
            return "redirect:/test_path"; //redirect to /test_path?message=OK
        }
    	
        @RequestMapping(value = "/test_path", method = RequestMethod.GET)
        public String doGet(ModelMap modelMap) {
    	// PROBLEM: After redirect from POST request,
            // I would like modelMap to have the same attributes as they were set in POST request.
        }
    }
    Thanks,
    Jarek
    Last edited by jaaro; Jul 13th, 2012, 07:49 AM.

  • #2
    You will have to add them manually. If you are on Spring 3.1 you can use RedirectAttributes and store them in a flashmap and have them added automatically.

    Comment

    Working...
    X