关于 java:GWT Maven 应用程序入口点未加载 | 珊瑚贝

GWT Maven Application Entry Point not loaded


我正在尝试构建一个新的 gwt 项目(也使用 maven 和 spring)。我的项目结构是:

– … 目录

  • myapp.admin-webapp
    –src/main/java
    — com.myapp.admin.webapp.client
    AdminEntryPoint.java
    — com.myapp.admin.webapp.client.presenter
    — com.myapp.admin.webapp.client.view
    — src/main/resources
    — com.myapp.admin
    webapp.gwt.xml
    – – Spring
    myapp.beans.xml
    — src/main/webapp
    myapp-admin.html
    myapp-admin.css
    — js
    — 元信息
    – – 资源
    — 网络信息
    应用程序上下文.xml
    web.xml

web.xml 文件:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?xml version=“1.0” encoding=“UTF-8”?>
<webapp version=“2.5” xmlns=“http://java.sun.com/xml/ns/javaee” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”
    xsi:schemaLocation=“http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd”>

    <welcomefilelist>
        <welcomefile>myappadmin.html</welcomefile>
    </welcomefilelist>

    <!– Add Support for Spring –>
    <!– Default applicationContext location: /WEBINF/applicationContext.xml –>
    <listener>
        <listenerclass>org.springframework.web.context.ContextLoaderListener</listenerclass>
    </listener>

    <!– exposes the request to the current thread –>
    <listener>
        <listenerclass>org.springframework.web.context.request.RequestContextListener</listenerclass>
    </listener>

    <!– UTF8 filter –>
    <filter>
        <filtername>characterEncodingFilter</filtername>
        <filterclass>org.springframework.web.filter.CharacterEncodingFilter</filterclass>
        <initparam>
            <paramname>encoding</paramname>
            <paramvalue>UTF8</paramvalue>
        </initparam>
        <initparam>
            <paramname>forceEncoding</paramname>
            <paramvalue>true</paramvalue>
        </initparam>
    </filter>
    <filtermapping>
        <filtername>characterEncodingFilter</filtername>
        <urlpattern>/*</url-pattern>
    </filter-mapping>

</web-app>

webapp.gwt.xml:

1
2
3
4
5
6
7
8
9
10
11
12
13
<?xml version=“1.0” encoding=“UTF-8”?>
<!DOCTYPE module SYSTEM“gwt-module.dtd”>

<module>

    <inherits name=‘com.google.gwt.user.User’/>

    <!– Specify the app entry point class. –>  
    <entrypoint class=‘myapp.admin.webapp.client.AdminEntryPoint’/>    

    <source path=‘myapp.admin.webapp.client’/>

</module>

我的简单入口点:

1
2
3
4
5
6
7
8
9
10
11
12
13
public class AdminEntryPoint implements EntryPoint {

    @Override
    public void onModuleLoad() {

        GWT.log(“Hello World!”, null);
        Label label = new Label(“Entry Point!”);
        label.setStyleName(“label”);
        RootPanel.get().add(label);
    }

}

还有我基本上是空的应用上下文:

1
2
3
4
5
6
7
8
9
<?xml version=“1.0” encoding=“UTF-8”?>
<beans xmlns=“http://www.springframework.org/schema/beans” xmlns:context=“http://www.springframework.org/schema/context”
    xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”
    xsi:schemaLocation=“http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd”
>

    <context:annotationconfig />

</beans>

当我尝试启动我的应用程序(IDE Eclipse)时,似乎没有问题。我可以使用”开发模式”启动我的应用程序并加载欢迎页面,但没有入口点。

当我尝试调试我的应用程序(将断点设置为 AdminEntryPoint 中的 onLoad 函数)时,它从未走得这么远。

所以看起来我的应用程序运行完美并且根本不知道它的入口点,尽管它是在 webapp.gwt.xml 中设置的。

感谢任何帮助:)

  • 请分享 myapp-admin.html。它是否在您的 html 文件中定义了 <script type=”text/javascript” \t\tsrc=”myapp/myapp.nocache.js”> ?在 gwt.xml 中定义 rename-to <module rename-to=’myapp’>。将源路径更改为 <source path=’client’ />


有些东西不见了。请更新或确认您的文件,如下所示:

webapp.gwt.xml:(添加重命名并更改源路径)

1
2
3
4
5
6
7
8
9
10
11
12
13
<?xml version=“1.0” encoding=“UTF-8”?>
<!DOCTYPE module SYSTEM“gwt-module.dtd”>

<module renameto=‘myapp’>

    <inherits name=‘com.google.gwt.user.User’/>

    <!– Specify the app entry point class. –>  
    <entrypoint class=‘myapp.admin.webapp.client.AdminEntryPoint’/>    

    <source path=‘client’/>

</module>

myapp-admin.html:(符合下一行)

1
<script type=“text/javascript” src=“myapp/myapp.nocache.js”>

在运行您的应用程序之前,删除所有 GWT 缓存文件并重新开始 GWT 编译。


来源:https://www.codenong.com/22254533/

微信公众号
手机浏览(小程序)
0
分享到:
没有账号? 忘记密码?