controller redirect is not working in spring mvc 3.2 with tiles 2

怎甘沉沦 提交于 2019-12-25 08:48:00

问题


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:


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;
}


来源:https://stackoverflow.com/questions/20332050/controller-redirect-is-not-working-in-spring-mvc-3-2-with-tiles-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!