Spring MVC Tiles重定向问题

时间:2014-06-25 19:20:47

标签: spring-mvc

我正在使用Spring MVC和Tiles。 当我尝试使用弹簧前缀"重定向:"对于重定向,我得到一个servlet异常 - "无法解析视图..."。

控制器

RequestMapping("/SUPPORT.lz")
public String generateSupportView(HttpServletRequest request)
{

    String url="http://"+request.getServerName()+":"+request.getServerPort()+"/APP";

    AuthenticatedUser user = getUser();
    /*
     * Check if a user has the role for the page he is trying to access. If
     * not redirect him to default page (home page).
     */
    if (user.getRoles() != null && !user.getRoles().contains(new Role(0, Role.RoleType.SUPPORT)))
    {
        return "redirect:"+url;
    }
    return "support.tiles";
}

调度-servlet.xml中

  <bean id="tilesViewResolver" 
        class="org.springframework.web.servlet.view.UrlBasedViewResolver"
        p:order="1"
        p:viewNames="*.tiles"
        p:viewClass="org.springframework.web.servlet.view.tiles2.TilesView"/>

  <bean id="nontilesViewResolver" 
        class="org.springframework.web.servlet.view.XmlViewResolver"
        p:order="2"
        p:location="/WEB-INF/app-nontiles-views.xml"/>

  <bean id="tilesConfigurer" 
        class="org.springframework.web.servlet.view.tiles2.TilesConfigurer" 
        p:definitions="/WEB-INF/app-tiles.xml"/>

  <bean id="messageSource" 
        class="org.springframework.context.support.ResourceBundleMessageSource"
        p:basename="i18n"/>

解决方案 -

我在disaptacher servlet.xml中添加了内部视图解析器,问题得到了解决。

 <bean id="viewResolver"
    class="org.springframework.web.servlet.view.InternalResourceViewResolver"
    p:order="3">
 </bean>

0 个答案:

没有答案