GWT:模块定义文件 (gwt.xml) 中定义的 CSS 文件不起作用?

GWT: CSS file defined in module definition file (gwt.xml) doesn't work?

从 GWT 教程 (http://www.gwtproject.org/doc/latest/DevGuideUiCss.html) 中,我们知道有多种方法可以将 CSS 文件与您的模块相关联。其中,一种方法是使用模块 XML 文件中的 <stylesheet> 元素。 当我使用这种方法时,我收到了下面的警告信息。好像这个方法不行。 这是module1.gwt.xml的内容:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.7.0//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.7.0/distro-source/core/src/gwt-module.dtd">
<module rename-to="entry1">
    <inherits name="com.google.gwt.user.User" />
    <inherits name='com.google.gwt.user.theme.clean.Clean'/>

    <source path="client" />
    <entry-point class="com.jst.gwt2.client.Entry1"></entry-point>
    <stylesheet src="../entry1.css" />
    <source path='client' />
    <source path='rpc' />
</module>

警告信息如下:

GET /entry1.css
   [WARN] ignored get request: /entry1.css
   [WARN] not handled: /entry1.css

引用@Thomas Broyer:
to get the full explanation click here

You'll have to change either

  • the path to your CSS (e.g. /entry1.css, but that won't necessarily work once deployed in production)
  • the location of your CSS (e.g. put it in your module's public path and reference it as <stylesheet src="entry1.css"/>)
  • the way you load it (e.g. inject it from your onModuleLoad, either as a StyleElement added to the Document; or possibly as a TextResource that you inject using StyleInjector –and use one less request to the server)