Results 1 to 2 of 2

Thread: Loading ModelMap from HTTP query parameters

  1. #1
    Join Date
    Jul 2012
    Posts
    1

    Default 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 at 06:49 AM.

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    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.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •