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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

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

  • 13-05-2015 8:27pm
    #1
    Registered Users, Registered Users 2 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, Registered Users 2 Posts: 94 ✭✭JohnPPP


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


  • Registered Users, Registered Users 2 Posts: 11,989 ✭✭✭✭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, Registered Users 2 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, Registered Users 2 Posts: 11,989 ✭✭✭✭Giblet


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


  • Registered Users, Registered Users 2 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, Registered Users 2 Posts: 11,989 ✭✭✭✭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, Registered Users 2 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, Registered Users 2 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, Registered Users 2 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, Registered Users 2 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, Registered Users 2 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, Registered Users 2 Posts: 11,989 ✭✭✭✭Giblet


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


  • Registered Users, Registered Users 2 Posts: 94 ✭✭JohnPPP


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

    Yep. Head is totally fried.


  • Registered Users, Registered Users 2 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