控制器重定向在带有磁贴2的Spring MVC 3.2中不起作用 [英] controller redirect is not working in spring mvc 3.2 with tiles 2
问题描述
在平铺解决了由控制器重定向的页面后,我没有显示该页面
I am not getting the page displayed ,after tiles resolving the page which was redirected by a controller
我有我的控制器
public ModelAndView addUser(){
if(success){
return new ModelAndView("redirect:myredirectPage.html");
}else {
--show error page---
}
}
并在同一控制器中
@RequestMapping(value="/myredirectPage", method=RequestMethod.GET)
public ModelAndView showMyRedirectPage(){
ModelAndView modelView = new ModelAndView("redirectPage");
return modelView;
}
我在日志中看到的全部是,tile正在解析重定向的视图,但是页面没有显示在浏览器中。
all I see in the my log is , tiles is resolving the redirected view, but the page is not getting displayed in the browser.
添加了模型对象'org.springframework.validatio
n.BindingResult。
类型的命令 [org.springframework.validation.BeanPropertyBin dingResult]以请求名称为 redirectPage的视图中的
2013年12月2日21:03:23
[http-apr-8080- exec-3]调试[org.springframework.web.servl
et.DispatcherServlet]-成功完成请求
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
我有spring配置文件视图解析器,其中瓦片视图解析器具有优先级。
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
推荐答案
您是否完全确定重定向的请求正在达到您的 showMyRedirectPage()
方法?该方法已映射到 / myredirectPage
,但是重定向请求将转到 myredirectPage.html
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
您是否尝试过将 .html
扩展名添加到 @RequestMapping
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;
}
这篇关于控制器重定向在带有磁贴2的Spring MVC 3.2中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!