包gwt客户端代码时丢失样式

时间:2017-09-18 21:08:43

标签: css maven gwt polymer

我使用GWT创建了一个网站,它完全由客户端代码组成。 .gwt.xml文件是:

<?xml version="1.0" encoding="UTF-8"?>
<!--
  When updating your version of GWT, you should also update this DTD reference,
  so that your app can take advantage of the latest GWT module capabilities.
-->
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.8.1//EN" "http://gwtproject.org/doctype/2.8.1/gwt-module.dtd">
<module rename-to='arithmeticexercisegeneratorclient'>
  <!-- Inherit the core Web Toolkit stuff.                        -->
  <inherits name='com.google.gwt.user.User'/>
  <inherits name='com.google.gwt.json.JSON'/>

    <!-- Inherit the default GWT style sheet.  You can change       -->
  <!-- the theme of your GWT application by uncommenting          -->
  <!-- any one of the following lines.                            -->
  <inherits name='com.google.gwt.user.theme.standard.Standard'/>
  <inherits name="com.vaadin.polymer.Elements"/>

  <!-- Other module inherits                                      -->
  <inherits name='com.github.nmorel.gwtjackson.GwtJackson'/>

  <!-- Specify the app entry point class.                         -->
  <entry-point class='com.onelostlogician.generator.exercise.arithmetic.client.ArithmeticExerciseGeneratorClient'/>

  <!-- Specify the paths for translatable code                    -->
  <!--<source path='client'/>-->

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

当我在devmode(mvn clean war:explosion gwt:devmode)中运行应用程序时,它看起来像我期望的那样:

enter image description here

但是当我打包代码并在浏览器中打开生成的网页时,它会丢失所有样式/格式:

enter image description here

基本html文件是

<!doctype html>
<html>
<head>
  <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1" />
  <link type="text/css" rel="stylesheet" href="ArithmeticExerciseGeneratorClient.css">
  <script type="text/javascript" src="arithmeticexercisegeneratorclient/arithmeticexercisegeneratorclient.nocache.js"></script>
</head>
<body>
  <div id="clientContent"></div>
  <noscript>
    <div style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif">
      Your web browser must have JavaScript enabled
      in order for this application to display correctly.
    </div>
  </noscript>
</body>
</html>

1 个答案:

答案 0 :(得分:1)

简单(但不太可能的答案)您的浏览器有一些奇怪的缓存,尝试按Ctrl + F5并查看是否修复了它。

如果您发现任何404错误,请检查网络面板,在这种情况下,您已找到丢失的拼图。

最后,您可以执行“mvn clean package”,然后深入了解WAR,找出您正在寻找的CSS缺失位置。

  

编辑:

你找到了恶作剧!

问题在于file://;通过HTTP访问这些文件,并且每个人都可以使用。

要进行快速测试,您可以直接上传服务器中的文件;或使用php -S ...docs)创建一个快速且脏的本地服务器。