2014-04-01 51 views
1

我使用gwt-maven-plugin和eclipse來創建GWT + Spring webapp。最後,我想讓.war文件被部署到某個應用服務器(tomcat等)。問題是生成的.war文件具有奇怪的結構。 enter image description heregwt-maven-plugin:webapp結構

然後我在Tomcat上運行的應用程序不工作 - SimpleGWT.html頁面有鏈接到的JavaScript文件,做所有的工作

<script type="text/javascript" language="javascript" src="SimpleGWT/SimpleGWT.nocache.js"></script> 

我的猜測是,由於SimpleGWT。 nocache.js位於不在WEB-INF內部的SimpleGWT文件夾內 - 無法訪問 有沒有任何方法可以改變gwt-maven-plugin的選項以獲得正常的webapp結構?這裏是我的pom.xml的一部分

<!-- GWT Maven Plugin --> 
    <plugin> 
    <groupId>org.codehaus.mojo</groupId> 
    <artifactId>gwt-maven-plugin</artifactId> 
    <version>2.6.0</version> 
    <executions> 
     <execution> 
     <goals> 
      <goal>compile</goal> 
     </goals> 
     </execution> 
    </executions> 
    <!-- Plugin configuration. There are many available options, see 
     gwt-maven-plugin documentation at codehaus.org --> 
    <configuration> 
     <inplace>true</inplace> 
     <runTarget>SimpleGWT.html</runTarget> 
     <hostedWebapp>${webappDirectory}</hostedWebapp> 
     <i18nMessagesBundle>com.javacodegeeks.gwtspring.client.Messages</i18nMessagesBundle> 
    </configuration> 
    </plugin> 
+0

你的意思是「正常的webapp結構」,你的WAR對我來說很好看。 (你的'SimpleGWT.html'和'SimpleGWT.css'不在'WEB-INF'中,那麼爲什麼你要'SimpleGWT.nocache.js'在'WEB-INF'中?)什麼是確切的錯誤/您看到將WAR文件部署到Tomcat的問題? –

+0

Tomcat不會抱怨。當SimpleGWT.html得到加載時,它說SimpleGWT/SimpleGWT.nocache.js - 404找不到。當我通過手動重組戰爭將這個腳本放入WEB-INF時,它可以工作 –

回答

0

它的問題主要與訪問HTML頁面中的靜態資源相關。

您正在使用relative path不是有一個「/」前綴。這是一個絕對路徑 指向Web服務器的根目錄。

Spring MVC應用程序org.springframework.web.servlet.DispatcherServlet負責爲web應用程序提供所有內容。

你定義爲url-pattern以上的servlet映射是什麼?請使用*.html/*作爲url-pattern

欲瞭解更多信息讀取Unable to load java script files in Jetty webapplication

+0

Braj,nochace.js不會從戰爭中遺失。它位於SimpleGWT文件夾內。但是當這場戰爭產生時,這個文件夾最終不在WEB-INF內部。所以當我在apache tomcat上運行這場戰爭時,瀏覽器無法下載腳本,因爲它不在WEB-INF內部。我嘗試並手動將SimpleGWT文件夾放入WEB-INF內,然後應用程序完美工作。然而,手動重組戰爭文件似乎對我來說有點褻瀆))) –

+0

'$ {webappDirectory}'的價值是什麼? – Braj

+0

mmm對不起...你的意思是在maven war插件中?我用maven插件使用eclipse。在我的內部我沒有戰爭插件。也許我應該發佈我的pom.xml? –