2015-11-04 68 views
0

我們在我們的Spring MVC應用程序瓷磚3中使用。有時(每第5或第10個服務器啓動)模板未加載。僅顯示.jsp頁面,不包含頁眉和頁腳。你有什麼建議,爲什麼?瓷磚模板有時不加載

的SpringConfig

@Bean 
    public InternalResourceViewResolver getInternalResourceViewResolver() { 
     InternalResourceViewResolver resolver = new InternalResourceViewResolver(); 
     resolver.setPrefix(JSP_PREFIX); 
     resolver.setSuffix(JSP_SUFFIX); 
     return resolver; 
    } 


    @Bean 
    public TilesConfigurer tilesConfigurer() { 
     TilesConfigurer tilesConfigurer = new TilesConfigurer(); 
     String[] defintions = new String[] { TILES_DEF }; 
     tilesConfigurer.setDefinitions(defintions); 
     return tilesConfigurer; 
    } 

    @Bean 
    public ViewResolver viewResolver() { 
     TilesViewResolver viewResolver = new TilesViewResolver(); 
     viewResolver.setCacheUnresolved(false); 
     return viewResolver; 
    } 

瓷磚,definition.xml

<?xml version="1.0" encoding="ISO-8859-1" ?> 

<!DOCTYPE tiles-definitions 
    PUBLIC "-//Apache Software Foundation//DTD Tiles Configuration 3.0//EN" "http://tiles.apache.org/dtds/tiles-config_3.0.dtd"> 

<tiles-definitions> 

    <definition name=".mainTemplate" template="/WEB-INF/jsp/fragments/template.jsp"> 
     <put-attribute name="header" value="/WEB-INF/jsp/fragments/header.jsp" /> 
     <put-attribute name="body" value="/WEB-INF/jsp/fragments/body.jsp" /> 
     <put-attribute name="footer" value="/WEB-INF/jsp/fragments/footer.jsp" /> 
    </definition> 



    <definition name="vermittlerUebersicht" extends=".mainTemplate"> 
     <put-attribute name="body" value="/WEB-INF/jsp/vermittlerUebersicht.jsp" /> 
    </definition> 

</tiles-definitions> 

而且template.jsp

<!DOCTYPE html> 
<%@ page pageEncoding="UTF-8" %> 
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%> 


    <tiles:insertAttribute name="header" /> 
    <tiles:insertAttribute name="body" /> 
    <tiles:insertAttribute name="footer" /> 

THX的幫助!

回答

0

我找到了解決方案!我在spring配置中有2個viewresolvers。因爲它不能確定首先處理請求的視圖解析器。我必須設置viewresolvers的順序。 InternalResourceViewResolver必須具有最低優先級(== hight訂單號)。