2013-11-20 31 views
1

我目前正在處理涉及Apache Tiles的項目,但遇到以下問題。
項目文件夾的路徑名中有(一個或多個)空格。現在Apache Tiles +文件夾路徑中的空白處

C:\Users\MyUsername\Documents\Dropbox\Subfolder\My Projects\GymApp 

,出乎我的意料,當我使用Apache瓷磚它試圖從以下位置加載tile-definition.xml

C:\Users\MyUsername\Documents\Dropbox\Subfolder\My%20Projects\GymApp\src\main\webapp\WEB-INF\configurations\tile-definition.xml 

所以,問題出在哪裏工具X會嘗試所有轉換部分空白到%20(URL編碼),其中工具X是:Windows,Java,Tomcat,Spring或Apache Tiles。由於此Apache Tiles無法加載文件,因爲該文件不存在(如果我嘗試在Windows資源管理器中打開URL,它會給我提供該文件不存在的錯誤,同樣的事情顯示在我的IDE的控制檯日誌中)。

至於我的問題,是否有可能在包含空格的文件夾中運行Apache Tiles項目?如果是這樣,這是如何完成的?

注意*:如果我將My Projects的文件夾名稱更改爲My_Projects,項目運行時沒有任何錯誤,所以我知道文件夾路徑在這裏有問題。

- 編輯 -
我使用此代碼來配置tilesConfigurer

<bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver"> 
    <property name="viewClass" value="org.springframework.web.servlet.view.tiles3.TilesView" /> 
</bean> 

<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles3.TilesConfigurer"> 
    <property name="definitions" value="/WEB-INF/configurations/tiles.xml" /> 
</bean> 

- 編輯2 -
這是我的IDE日誌顯示:

DEBUG BaseLocaleUrlDefinitionDAO:154 - File Resource file:/C:/Users/MyUsername/Documents/Dropbox/Subfolder/My%20Projects/GymApp/src/main/webapp/WEB-INF/configurations/tiles.xml at file:/C:/Users/MyUsername/Documents/Dropbox/Subfolder/My%20Projects/GymApp/src/main/webapp/WEB-INF/configurations/tiles.xml not found, continue 
DEBUG BaseLocaleUrlDefinitionDAO:154 - File Resource file:/C:/Users/MyUsername/Documents/Dropbox/Subfolder/My%20Projects/GymApp/src/main/webapp/WEB-INF/configurations/tiles_en.xml at file:/C:/Users/MyUsername/Documents/Dropbox/Subfolder/My%20Projects/GymApp/src/main/webapp/WEB-INF/configurations/tiles_en.xml not found, continue 
DEBUG TestDispatcherServlet:938 - Could not complete request 
javax.servlet.ServletException: Could not resolve view with name 'home' in servlet with name '' 
+0

我也遇到了這個問題。你找到了解決這個問題的方法嗎? – jonasespelita

+0

@jonasespelita不幸的是,我'固定'它沒有使用任何空白的路徑。 –

回答

0

待辦事項在指定tilesConfigurer bean時使用上下文相關路徑?因爲如果你這樣做,你的項目文件夾是否包含空格應該沒有關係。

我有我的調度員servlet.xml中下面的代碼:

<bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver"> 
    <property name="viewClass" value="org.springframework.web.servlet.view.tiles3.TilesView" /> 
</bean> 
<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles3.TilesConfigurer"> 
    <property name="definitions"> 
     <list> 
      <value>/WEB-INF/tiles/config/template-definitions.xml</value> 
      <value>/WEB-INF/tiles/config/page-definitions.xml</value> 
     </list> 
    </property> 
</bean> 

...即使我的項目文件夾中包含空格,瓷磚還發現在定義XML。

+0

我添加了我使用的代碼和我的JUnit + MockMvc測試的錯誤日誌。使用「正確的」項目路徑運行相同的測試可以毫無錯誤地通過測試。 –