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

  • RedirectView and query parameters

    Hello,

    I understand from the RedirectView API documentation that: "View that redirects to an absolute, context relative, or current request relative URL, by default exposing all model attributes as HTTP query parameters."

    I tried the following in my Controller:

    Code:
    Map<String, Object> model = new HashMap<String, Object>();
    model.put("someParameterName", "someParameterValue");
    return new ModelAndView(new RedirectView("/index.jsp", true), "model", model);
    I get redirected to /index.jsp, however, the model attribute someParameterName is not added as a query parameter. I must be doing something wrong?

    Any help greatly appreciated,
    Nes

  • #2
    The code you provided is adding your map (named "model") to the model as an attribute, instead of using it as the model. Try this instead:

    Code:
    ModelAndView mav = new ModelAndView(new RedirectView("/index.jsp", true));
    mav.addObject("someParameterName", "someParameterValue");
    return mav;

    Comment


    • #3
      Thanks for this solution

      Comment

      Working...
      X