我有一个使用gwt-maven-archetype构建的Maven项目.虽然它与mvn gwt:run目标运行完美,但是当我尝试在tomcat7容器中运行它时mvn tomcat:run或mvn gwt:compile&& mvn tomcat:运行它不加载GWT动态创建的小部件.

根据谷歌Chrome控制台,它找不到* .nocache.js文件,即使在/ target /文件夹中它正好在预期的位置.

我目前正在尝试在入口点模块中显示一个简单的“Hello”标签:

GWT入口点

public class Hello implements EntryPoint {


    public void onModuleLoad() {    
        Label hello = new Label("TESTESTSTSTS");

        RootPanel.get("helloContainer").add(hello);

    }

}

*.html的

<html>
  <head>
    <Meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <link type="text/css" rel="stylesheet" href="veltisto.css">
    <title>Web Application Starter Project</title>
    <script type="text/javascript" language="javascript" src="veltisto/veltisto.nocache.js"></script>
  </head>
  <body>
    <iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe>
    <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>
    <div id="helloContainer"></div>
  </body>
</html>

的pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

    <!-- POM file generated with GWT webAppCreator -->
    <modelVersion>4.0.0</modelVersion>
    <groupId>gr.veltisto</groupId>
    <artifactId>web</artifactId>
    <packaging>war</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>GWT Maven Archetype</name>

    <properties>
        <!-- Convenience property to set the GWT version -->
        <gwtVersion>2.4.0</gwtVersion>
        <!-- GWT needs at least java 1.5 -->
        <webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-servlet</artifactId>
            <version>${gwtVersion}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-user</artifactId>
            <version>${gwtVersion}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.7</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>1.0.0.GA</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>1.0.0.GA</version>
            <classifier>sources</classifier>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.github.gwtbootstrap</groupId>
            <artifactId>gwt-bootstrap</artifactId>
            <version>2.0.4.0</version>
        </dependency>
    </dependencies>

    <build>
        <!-- Generate compiled stuff in the folder used for developing mode -->
        <outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>

        <plugins>

            <!-- copy static web files before executing gwt:run -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1.1</version>
                <executions>
                        <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>exploded</goal>
                                </goals>
                        </execution>
                </executions>
                <configuration>
                    <webappDirectory>${webappDirectory}</webappDirectory>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.5</source>
                    <target>1.5</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.0</version>
                <configuration>             
                    <path>/veltisto</path>
                </configuration>
            </plugin>


            <!-- GWT Maven Plugin -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>gwt-maven-plugin</artifactId>
                <version>2.4.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>
                    <runTarget>veltisto.html</runTarget>
                    <hostedWebapp>${webappDirectory}</hostedWebapp>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

* .GWT.XML

<module rename-to='veltisto'>
    <!-- Inherit the core Web Toolkit stuff. -->
    <inherits name='com.google.gwt.user.User' />
    <inherits name="com.google.gwt.uibinder.UiBinder" />
    <!-- We need the JUnit module in the main module,-->
    <!-- otherwise eclipse complains (Google plugin bug?) -->
    <inherits name='com.google.gwt.junit.JUnit' />

    <!-- 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.google.gwt.user.theme.chrome.Chrome'/> -->
    <!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->

    <!-- Other module inherits -->

    <inherits name="com.google.gwt.uibinder.UiBinder" />
    <inherits name="com.github.gwtbootstrap.Bootstrap" />

    <!-- Specify the app entry point class. -->
    <entry-point class='gr.veltisto.web.client.Hello' />

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

</module>

解决方法

tomcat7:run只使用src / main / webapp.你将要使用tomcat7:run-war(将执行一个包)或tomcat7:run-war-only(如果你已经有一个war:爆炸结构).

GWT不加载* .nocache.js的更多相关文章

  1. ajax – 将spring 3 mvc与GWT集成的经验?

    鉴于:Spring3.0mvc具有优秀的REST支持,其中一个表示形式是JSON。>默认GWT的MVP体系结构只适用于客户端,并且可以很好地与JSON一起工作吗?谢谢可以分享使用Spring3.0mvc与GWT的经验吗?我们已经在GWT和SpringMVC成功构建了一个全面的大型应用程序。Spring是项目成功的关键。只有在Spring中,我们才能在服务器端单独测试一些应用程序。忽略GWT使用的默认Servlet,并创建自己的Spring控制器来处理传入的GWT-RPC请求。如果您遵循指南,GWT的MVP

  2. 用于重AJAX Java应用程序的最佳服务器端框架

    有7万个JavaWeb应用程序框架.95%是在现代AJAX/DHTML开发之前设计的,这意味着这些新方法被嫁接而不是设计.有没有任何框架从头开始构建,例如.GWT+Extjs在想?如果不是,哪个框架最适合于具有动态数量的字段和页面的形式的世界,变形客户端?

  3. ajax – 会话管理在gwt

    我正在使用GWT作为我的客户端应用程序.但是,我不知道如何处理会话管理.GWT应用程序位于一个页面上,所有服务器调用都通过AJAX完成.如果会话在服务器上过期.我们假设用户没有关闭浏览器,并使用RPC向服务器发送一些请求,我的服务器如何通知应用程序会话已过期,客户端部分应该再次显示登录屏幕?

  4. ajax – 在GWT中点击?

    我正在使用GWT构建一个AJAXWeb应用程序,我想使用右键单击各种内容,就像在桌面应用程序中一样.但是,右键单击会生成标准Web上下文菜单,并且永远不会调用voidonClick.有没有人想出如何让这个工作?pageId=425996最后,您将要禁用浏览器菜单以完全重载此类上下文菜单.除了opera之外,这应该适用于所有浏览器.但老实说,这几天新人使用了^_______^

  5. 用GWT实现基于Ajax的Web开发

    本文将结合GWTDesigner,以一个小型Web应用系统为例,对基于GWT的Web应用开发进行完整的介绍。使用GWT进行AjaxWeb应用程序开发的优势GoogleWebToolkit是Google公司推出的一款基于Java的AjaxWeb应用程序开发框架。Eclipse集成了对GWT脚本的支持,在Eclipse环境下使用GWT开发AjaxWeb应用程序,无论是代码编写、组织、测试还是调试,都能够获得较高的生产力。基于Eclipse的GWT开发环境是业界公认的,最佳的GWT开发环境。

  6. GWT入门学习与理解

    前言最近在一家公司实习,公司使用的是GWT技术进行项目的开发。因此笔者接下来会进入到GWT到初步学习中,整理一些知识点,写入博客。GWT技术简介来源:网络、《GWT入门与经典实例解析》GWT全称为GooglewebToolkit,是Google公司发布的基于Java语言开发AJAX应用的开发工具包。

  7. java – 为什么需要gwt-bootstrap?

    为什么它甚至需要gwt-bootstrap?解决方法我启动了GWT-Bootstrap,意图将引导程序JS和CSS绑定到可重用的GWT组件,否则,您可能需要复制代码,这可能会以您创建自己的代码结束,这可能与GWT非常相似–引导.它还有一些绑定事件等的工具.但是,回答你的主要问题:这取决于.如果你不信任社区和/或有很多时间,你可以做自己的gwt-bootstrap项目,但可能与你的项目集成,至少,这是我的情况发生的事情……

  8. java – 自定义ValueChangeHandler GWT

    我需要编写一个自定义ValueChangeHandler并调用onValueChange.但是我不明白如何编写ValueChangeEvent.也许我理解整个GWT事件系统是错误的.有人可以帮忙吗?

  9. java – 摆脱GWT MVP样板

    关于地点和附件的文件活动MVP,我必须创建的每个页面:>一个地方>一项活动>一个标记化器(我必须实现标记化逻辑)>演示者的界面(活动实现此界面)>视图的界面>视图实现>用于视图实现的uibinderxml>app活动映射器中的节点>gin模块中的一个节点,用于绑定视图接口以查看实现我创建了一个具有基本功能的应用程序(5页和导航栏),我已经有超过1500行代码和~40个文件.我认为这是完全不可维护的

  10. java – 任何其他GXT主题?

    默认情况下出现的GXT主题还可以,但它们基本上都是不同颜色的同一个版本.环顾四周,我找不到任何有吸引力的商业或免费主题.有没有找到新主题的好地方,或者到目前为止还没有出现第三方市场?

随机推荐

  1. js中‘!.’是什么意思

  2. Vue如何指定不编译的文件夹和favicon.ico

    这篇文章主要介绍了Vue如何指定不编译的文件夹和favicon.ico,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教

  3. 基于JavaScript编写一个图片转PDF转换器

    本文为大家介绍了一个简单的 JavaScript 项目,可以将图片转换为 PDF 文件。你可以从本地选择任何一张图片,只需点击一下即可将其转换为 PDF 文件,感兴趣的可以动手尝试一下

  4. jquery点赞功能实现代码 点个赞吧!

    点赞功能很多地方都会出现,如何实现爱心点赞功能,这篇文章主要为大家详细介绍了jquery点赞功能实现代码,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

  5. AngularJs上传前预览图片的实例代码

    使用AngularJs进行开发,在项目中,经常会遇到上传图片后,需在一旁预览图片内容,怎么实现这样的功能呢?今天小编给大家分享AugularJs上传前预览图片的实现代码,需要的朋友参考下吧

  6. JavaScript面向对象编程入门教程

    这篇文章主要介绍了JavaScript面向对象编程的相关概念,例如类、对象、属性、方法等面向对象的术语,并以实例讲解各种术语的使用,非常好的一篇面向对象入门教程,其它语言也可以参考哦

  7. jQuery中的通配符选择器使用总结

    通配符在控制input标签时相当好用,这里简单进行了jQuery中的通配符选择器使用总结,需要的朋友可以参考下

  8. javascript 动态调整图片尺寸实现代码

    在自己的网站上更新文章时一个比较常见的问题是:文章插图太宽,使整个网页都变形了。如果对每个插图都先进行缩放再插入的话,太麻烦了。

  9. jquery ajaxfileupload异步上传插件

    这篇文章主要为大家详细介绍了jquery ajaxfileupload异步上传插件,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

  10. React学习之受控组件与数据共享实例分析

    这篇文章主要介绍了React学习之受控组件与数据共享,结合实例形式分析了React受控组件与组件间数据共享相关原理与使用技巧,需要的朋友可以参考下

返回
顶部