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

  • RedirectView and Model object

    I am having great difficulty in using the RedirectView and pasing a model - no matter what I have tried I cannot access the model in the view although I can see it as a parameter in the url.

    In the onSubmit method of the controller I have tried the following:

    Code:
    return new ModelAndView(new RedirectView(getSuccessView())).addObject("model" ,"testmsg");
    Code:
    return new ModelAndView(new RedirectView(getSuccessView()), "model" ,"testmsg");
    In the view (JSP) I am trying to display as so:

    Code:
    <c:out value="${model}"/>
    Code:
    <%=request.getAttribute("model")%>
    I've also attempted to redirect to a 2nd controller and found that the data cannot be found in the request, I've also attempted to use a interceptor (following the advice of another member in the forums) and this also proved fruitless.

    I'm fresh out of ideas and any help would be great.

  • #2
    I am now able to extract the parameters from the request.getParameterNames() but this is an inelegant solution plus I was hoping to set the RedirectView object to hide the exposed model using the method setExposeModelAttributes - yet at the same time be able to access them.

    I suppose this is not possible? I really do not wish for users to see the data being passed.

    Comment


    • #3
      No, that's not possible. A redirect is a GET request, not a POST. Only solution is to keep the model on the server on to init the redirect without the model.

      Joerg

      Comment


      • #4
        I am having trouble getting the model in referenceData() of the new controller.

        Here is what I am doing..

        Code:
        Map model;
        
        ModelAndView modelAndView = new ModelAndView(new RedirectView("showMyNewTarget.do"));
        modelAndView.addObject("targetModel", model);
        return modelAndView;
        In the URL I do see targetModel with the correct data. How do I get it off the URL in my referenceData() of the controller? Please help.

        I have tried both of the following but nothing seems to work.

        Code:
         Map empModel = (Map) request.getAttribute("targetModel");

        Code:
         Map empModel = (Map) request.getParameterMap();

        Comment

        Working...
        X