controller redirect is not working in spring mvc 3

2019-09-05 16:47发布

I am not getting the page displayed ,after tiles resolving the page which was redirected by a controller

I have my controller

public ModelAndView addUser(){
   if(success){
      return new ModelAndView("redirect:myredirectPage.html");
   }else {
          --show error page---
   }
}

and in the same controller

@RequestMapping(value="/myredirectPage", method=RequestMethod.GET)
public ModelAndView showMyRedirectPage(){
   ModelAndView modelView = new ModelAndView("redirectPage");
   return modelView;
}

all I see in the my log is , tiles is resolving the redirected view, but the page is not getting displayed in the browser.

Added model object 'org.springframework.validatio n.BindingResult.command' of type [org.springframework.validation.BeanPropertyBin dingResult] to request in view with name 'redirectPage' 02 Dec 2013 21:03:23 [http-apr-8080-exec-3] DEBUG [org.springframework.web.servl et.DispatcherServlet] - - Successfully completed request

and I have spring config file view resolver, where tiles view resolver is given priority.

<bean id="viewResolver"
    class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="order" value="1"></property>
    <property name="prefix" value="/jsp/" />
    <property name="suffix" value=".jsp" />
</bean>
<bean id="TilesviewResolver"
    class="org.springframework.web.servlet.view.UrlBasedViewResolver">
    <property name="order" value="0"></property>
    <property name="viewClass">
        <value>
            org.springframework.web.servlet.view.tiles2.TilesView
        </value>
    </property>
</bean>
<bean id="tilesConfigurer"
    class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
    <property name="definitions">
        <list>
            <value>/WEB-INF/tiles.xml</value>
        </list>
    </property>
</bean>

cant able to debug, since I am not getting any error on logs. appreciate yours responses

1条回答
相关推荐>>
2楼-- · 2019-09-05 16:54

Are you absolutely sure that the redirected request is hitting your showMyRedirectPage() method? That method is mapped to /myredirectPage but the redirect request is going to myredirectPage.html

Have you tried adding the .html extension to your @RequestMapping

@RequestMapping(value="/myredirectPage.html", method=RequestMethod.GET)
public ModelAndView showMyRedirectPage(){
   ModelAndView modelView = new ModelAndView("redirectPage");
   return modelView;
}
查看更多
登录 后发表回答