Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Going from one model and view to another model and view. Weird issue.

Options
  • 13-05-2015 9:27pm
    #1
    Registered Users Posts: 94 ✭✭


    Posted this on SO the other day but haven't had any replies. Think I've explained it okay but if I haven't let me know.

    Basically my new model and view is getting inserted in to the first model and view rather than going to an entire new jsp. Can't figure out why it's doing this at all :/

    stackoverflow.com/questions/30155100/redirecting-in-controller-from-one-model-and-view-to-another


Comments

  • Registered Users Posts: 94 ✭✭JohnPPP


    Sorry, still can't post links so had to remove http.


  • Registered Users Posts: 11,979 ✭✭✭✭Giblet


    If you are returning javascript (or the call is consumed by javascript on the front end), you can only redirect by returning
    window.location ="myurl"


  • Registered Users Posts: 94 ✭✭JohnPPP


    Giblet wrote: »
    If you are returning javascript (or the call is consumed by javascript on the front end), you can only redirect by returning
    window.location ="myurl"

    Not returning javascript (that I know of anyway) and I can't see the front end doing that either. It's just a form with a submit button essentially. Using a fancy bootstrap template.


  • Registered Users Posts: 11,979 ✭✭✭✭Giblet


    Check the network data in Chrome, post a HAR file if you can.


  • Registered Users Posts: 94 ✭✭JohnPPP


    Can't seem to post the HAR here. But just checked the response and the response is the entire JSP page (including some javascript by the looks of it, not much though). Could this really be causing this issue?

    I'm so confused. How is my first modelAndView even still around after returning an entirely different modelAndView

    Spent hours on this so far :(


  • Advertisement
  • Registered Users Posts: 11,979 ✭✭✭✭Giblet


    It seems you are returning a rendered view rather than a redirect action to different view, so it might be rendering weirdly.
    return new ModelAndView("redirect:/someaction")
    


  • Registered Users Posts: 94 ✭✭JohnPPP


    Giblet wrote: »
    It seems you are returning a rendered view rather than a redirect action to different view, so it might be rendering weirdly.
    return new ModelAndView("redirect:/someaction")
    

    Tried that before too and it doesn't work. Thanks though.


  • Registered Users Posts: 94 ✭✭JohnPPP


    It is something like that though, since the url isn't changing when I hit the search button. Tried using ModelAndView("redirect:/room-list") and more combinations include jsp at the end etc but no luck


  • Registered Users Posts: 94 ✭✭JohnPPP


    Just looked at dev tools for the request that gets sent when using redirect. It seems to be trying to go to another controller (ie going to site.com/room-list?param1=hello) for example. I want it to go to room-list.jsp


  • Registered Users Posts: 94 ✭✭JohnPPP


    I think I need response.sendRedirect but keep getting 404s at room-list. Trying to figure out how to get the correct path to my jsp now


  • Advertisement
  • Registered Users Posts: 94 ✭✭JohnPPP


    4 hours later today aline and I'm no further. Ffs. No matter what I do it just won't go to the new jsp


  • Registered Users Posts: 11,979 ✭✭✭✭Giblet


    Have you set method="post" on the form?


  • Registered Users Posts: 94 ✭✭JohnPPP


    Giblet wrote: »
    Have you set method="post" on the form?

    Yep. Head is totally fried.


  • Registered Users Posts: 569 ✭✭✭none


    Did you configure Spring MVC with a correct View Resolver like below?

    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="WEB-INF/views/"/>
    <property name="suffix" value=".jsp"/>
    </bean>

    http://forum.spring.io/forum/spring-projects/web/93945-jsp-not-found-after-redirect


Advertisement