2016-07-07 68 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仍然指的是旧文件。一旦我找出了编译过程,它就已经修复了。