我使用mgwt和GWTP。本页介绍了如何生成Html5Manifest文件。
当在开发模式下运行我的应用程序时,我得到以下错误:
[WARN] /testmobile.manifest
javax.servlet.ServletException: unkown device
at com.googlecode.mgwt.linker.server.Html5ManifestServletBase.doGet(Html5ManifestServletBase.java:115)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:324)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:829)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:513)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
[ERROR] 500 - GET /testmobile.manifest (192.168.178.21) 3009 bytes
这是我的gwt.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.5.1//EN"
"http://google-web-toolkit.googlecode.com/svn/tags/2.5.1/distro-source/core/src/gwt-module.dtd">
<module rename-to='testmobile'>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name="com.google.gwt.user.User"/>
<inherits name='com.google.gwt.core.Core'/>
<inherits name='com.google.gwt.inject.Inject' />
<inherits name='com.google.gwt.resources.Resources' />
<inherits name="com.googlecode.mgwt.MGWT"/>
<!-- Other module inherits -->
<inherits name='com.gwtplatform.dispatch.Dispatch'/>
<inherits name='com.gwtplatform.mvp.Mvp' />
<inherits name="com.googlecode.mgwt.linker.Linker" />
<add-linker name="permutationmaplinker" />
<extend-configuration-property name="html5manifestlinker_files" value="./" />
<extend-configuration-property name="html5manifestlinker_files" value="index.html" />
<extend-configuration-property name="html5manifestlinker_files" value="index.css" />
<!-- Specify the app entry point class. -->
<entry-point class='test.mobile.client.Testgwtp'/>
<inherits name="com.google.gwt.logging.Logging" />
<set-property name="gwt.logging.logLevel" value="INFO" />
<set-property name="gwt.logging.enabled" value="TRUE" />
<set-property name="gwt.logging.popupHandler" value="DISABLED" />
<set-property name="gwt.logging.developmentModeHandler" value="ENABLED" />
<set-configuration-property name="gin.ginjector.modules"
value="test.mobile.client.gin.ClientModule"/>
<set-property name="user.agent" value="safari" />
<!-- Specify the paths for translatable code -->
<source path='client'/>
<source path='shared'/>
</module>
这是我的web.xml文件:
<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<!-- https://code.google.com/p/mgwt/wiki/HTML5Manifest -->
<servlet>
<servlet-name>ManifestServlet</servlet-name>
<servlet-class>com.googlecode.mgwt.linker.server.MGWTHtml5ManifestServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ManifestServlet</servlet-name>
<url-pattern>/testmobile.manifest</url-pattern>
</servlet-mapping>
这是我的index.html文件:
<html manifest="/testmobile.manifest">
<head>
<title>test</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link type="text/css" rel="stylesheet" href="index.css">
<script type="text/javascript" language="javascript" src="testmobile/testmobile.nocache.js"></script>
</head>
<body>
<!-- OPTIONAL: include this if you want history support -->
<iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe>
</body>
</html>
如何防止此错误
编辑:我在这里找到的https://code.google.com/p/mgwt/issues/detail?id=294当你改变默认排列时,你必须改变排列,但我不知道怎么做?
编辑:插入后
<add-linker name="xsiframe"/>
在我的web.xml文件中,我有一个compilation-mappings.txt文件,其中包含以下内容:
3CF5F28779DC3102DF51566915301A19.cache.js
locale default
mobile.user.agent mobilesafari
4086115B0405F7965FF008436AFD8C97.cache.js
locale de
mobile.user.agent mobilesafari
69E3CCD13FF82D3DA3EBC7EDAE5A1588.cache.js
locale de
mobile.user.agent not_mobile
C35440AF74DD89E43810D85756CC4CEE.cache.js
locale default
mobile.user.agent not_mobile
Devmode:devmode.js
如果将<inherits name="com.googlecode.mgwt.MGWT" />
添加到gwt.xml文件中,它应该可以工作。
一些属性(即mgwt.os和mobile.user.agent,我想)可能不存在。它们有助于决定必须送达哪份舱单。
在html文件中删除模块名称前的"/"
<html manifest="/testmobile.manifest">
它应该看起来像
<html manifest="testmobile.manifest">