2016-07-07 73 views
0

我已經創建了Eclipse示例GWT + AppEngine項目,並添加了一個contact.gwt.xml文件作爲客戶端。它對應*.contact.nocache.js創建自contact.html未更新代碼更改。我在內部Jetty服務器上的本地主機上運行它。* .nocache.js未重新載入最新的代碼更改(使用Restlet和GWT)

這是我的文件。

contact.html

<!doctype html> 
<html> 
<head> 
<meta http-equiv="content-type" content="text/html; charset=UTF-8"> 
<title>contact</title> 
<script type="text/javascript" laguage="javascript" 
    src="contact/org.restlet.example.firstapplication.contact.nocache.js?dummyTimeParam=<%=System.currentTimeMillis() %>"></script> 
</head> 

<body> 
    <h1>About a contact</h1> 

    <table> 
     <tr> 
      <th>Contact 102</th> 
      <th>Home address</th> 
     </tr> 
     <tr> 
      <td id="contactContainer" style="vertical-align: top"></td> 
      <td id="homeAddressContainer"></td> 
     </tr> 
     <tr> 
      <td id="buttonContainer" colspan="2"></td> 
     </tr> 
    </table> 
</body> 
</html> 

contact.gwt.xml

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.4.0//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.4.0/distro-source/core/src/gwt-module.dtd"> 
<module> 
    <inherits name="com.google.gwt.user.User" /> 
    <inherits name="org.restlet.Restlet" /> 
    <source path="client" /> 
    <source path="shared" /> 
    <inherits name='com.google.gwt.user.theme.clean.Clean' /> 
    <entry-point class='org.restlet.example.firstapplication.client.ContactModule' /> 

     <!-- allow Super Dev Mode --> 
     <add-linker name="xsiframe"/> 
</module> 

appengine.web.xml

<static-files> 
    <include path="**" /> 

    <!-- The following line requires App Engine 1.3.2 SDK --> 
    <include path="**.nocache.*" expiration="0s" /> 

    <include path="**.cache.*" expiration="365d" /> 
    <exclude path="**.gwt.rpc" /> 
    </static-files> 

的Restlet應用模塊的有關部分

public class TestServerApplication extends Application { 

    @Override 
    public Restlet createInboundRoot() { 
     Router router = new Router(getContext()); 

     Directory dir = new Directory(getContext(), "war:///"); 
     router.attachDefault(dir); 
     router.attach("/contacts/123", ContactServerResource.class); 

     return router; 
    } 

} 

無論我在contact.html文件中做出什麼修改,它都會更新,但其相應的Java文件onModule()永遠不會被調用。它始終獲得.nocache.js文件的304響應代碼,該文件從「/ war/contact /」位置獲取相同的.cache.html文件。

我認爲,我需要添加過濾器,如此處所述(how to clear cache in gwt?),但我不確定發生了什麼以及如何在此處不使用Java servlet的情況下添加此過濾器。任何幫助,將不勝感激。

+1

它看起來像你的'* .nocache.js'被緩存在瀏覽器中(或者在一些代理中)。嘗試清除瀏覽器緩存並重新加載頁面。如果有效,這將確認緩存問題,並且您需要以某種方式強制Web服務器發送緩存標頭。 – Adam

+0

感謝您的提示。從我的結局來看,這是一個錯誤。 – Junaid

回答

0

我不知道現在是否可以刪除此問題。但從我的結局來看,這是一個愚蠢的錯誤。我從另一個項目複製了代碼,並將軟件包名稱更改爲「org.example.contact」。爲以前的包創建的/war/<oldPackageName>/*.nocache.js仍然存在,並且正在HTML文件中進行鏈接。當我用新軟件包重新編譯代碼時,它創建了一個新的/war/<newPackageName>/*.nocache.js文件,但HTML仍然指的是舊文件。一旦我找出了編譯過程,它就已經修復了。