gpt4 book ai didi

java - GWT 2.4 IE8 问题

转载 作者:行者123 更新时间:2023-11-30 09:18:09 26 4
gpt4 key购买 nike

我正在使用 GWT 2.4(我无法将我的版本升级到 2.5)我遇到以下问题:当我使用 Chrome、Firefox 或 Internet Explorer 9 或 10 时,我的系统运行良好;通过使用 Internet Explorer 8,我的系统根本无法工作;它向用户显示一个空白页面,我收到以下 javascript 错误:

Dettagli errore pagina Web

Agente utente: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0) Timestamp: Thu, 5 Sep 2013 10:56:58 UTC

Messaggio: Argomento non valido. Linea: 28410 Carattere: 54 Codice: 0 URI: http://app.it:8080/myApp/F662F41B287D1686DCB056062754DFEB.cache.html

我在网上搜索,找到了这个链接:https://code.google.com/p/google-web-toolkit/issues/detail?id=6665在这个 GWT 问题中,解释了 GWT 2.4 在 IE8 和 chromeframe 上存在一些问题;我按照他们的建议做了;事实上我所做的是:

  • 在我的应用程序 HTML 页面中,我添加了以下元标记:meta http-equiv="X-UA-Compatible"content="IE=edge,chrome=1"
  • 我创建了我的自定义 PropertyProviderGenerator(参见下面的代码)
  • 在我的 .gwt.xml 文件中,我指定使用我的自定义 PropertyProviderGenerator(参见下面的代码)

PropertyProviderGenerator

import com.google.gwt.core.ext.TreeLogger;
import com.google.gwt.core.ext.linker.ConfigurationProperty;
import com.google.gwt.core.ext.linker.PropertyProviderGenerator;

import java.util.Arrays;
import java.util.List;
import java.util.SortedSet;

public class CustomUserAgentPropertyGenerator implements PropertyProviderGenerator {

private static final List<String> VALID_VALUES = Arrays.asList(new String[]{"ie6", "ie8", "gecko1_8", "safari", "opera", "ie9"});

private static UserAgentPropertyGeneratorPredicate[] predicates =
new UserAgentPropertyGeneratorPredicate[] {

// opera
new UserAgentPropertyGeneratorPredicate("opera")
.getPredicateBlock()
.println("return (ua.indexOf('opera') != -1);")
.returns("'opera'"),

// webkit family (chrome, safari and chromeframe).
new UserAgentPropertyGeneratorPredicate("safari")
.getPredicateBlock()
.println("return (ua.indexOf('webkit') != -1);")
.returns("'safari'"),

// IE9
new UserAgentPropertyGeneratorPredicate("ie9")
.getPredicateBlock()
.println("return (ua.indexOf('msie') != -1 && ($doc.documentMode >= 9));")
.returns("'ie9'"),

// IE8
new UserAgentPropertyGeneratorPredicate("ie8")
.getPredicateBlock()
.println("return (ua.indexOf('msie') != -1 && ($doc.documentMode >= 8));")
.returns("'ie8'"),

// IE6
new UserAgentPropertyGeneratorPredicate("ie6")
.getPredicateBlock()
.println("var result = /msie ([0-9]+)\\.([0-9]+)/.exec(ua);")
.println("if (result && result.length == 3)")
.indent()
.println("return (makeVersion(result) >= 6000);")
.outdent()
.returns("'ie6'"),

// gecko family
new UserAgentPropertyGeneratorPredicate("gecko1_8")
.getPredicateBlock()
.println("return (ua.indexOf('gecko') != -1);")
.returns("'gecko1_8'"),
};

static void writeUserAgentPropertyJavaScript(SourceWriter body, SortedSet<String> possibleValues) {

// write preamble
body.println("var ua = navigator.userAgent.toLowerCase();");
body.println("var makeVersion = function(result) {");
body.indent();
body.println("return (parseInt(result[1]) * 1000) + parseInt(result[2]);");
body.outdent();
body.println("};");

// write only selected user agents
for (int i = 0; i < predicates.length; i++) {
if (possibleValues.contains(predicates[i].getUserAgent())) {
body.println("if ((function() { ");
body.indent();
body.print(predicates[i].toString());
body.outdent();
body.println("})()) return " + predicates[i].getReturnValue() + ";");
}
}

// default return
body.println("return 'unknown';");
}

public String generate(TreeLogger logger, SortedSet<String> possibleValues, String fallback, SortedSet<ConfigurationProperty> configProperties) {
for (String value : possibleValues) {
if (!VALID_VALUES.contains(value)) {
logger.log(TreeLogger.WARN, "Unrecognized "
+ UserAgentGenerator.PROPERTY_USER_AGENT + " property value '"
+ value + "', possibly due to UserAgent.gwt.xml and "
+ UserAgentPropertyGenerator.class.getName()
+ " being out of sync." + " Use <set-configuration-property name=\""
+ UserAgentGenerator.PROPERTY_USER_AGENT_RUNTIME_WARNING
+ "\" value=\"false\"/> to suppress this warning message.");
}
}
assert predicates.length == VALID_VALUES.size();
StringSourceWriter body = new StringSourceWriter();
body.println("{");
body.indent();
writeUserAgentPropertyJavaScript(body, possibleValues);
body.outdent();
body.println("}");
return body.toString();
}
}

MySystem.gwt.xml

<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='mysystem'>
<!-- some inherits -->
<property-provider name="user.agent" generator="com.google.gwt.user.rebind.mysystemUserAgentPropertyGenerator"/>
<inherits name="com.google.gwt.user.UserAgent"/>
<set-configuration-property name="user.agent.runtimeWarning" value="false"/>
<!-- the rest of the file -->
<extend-property name="locale" values="en, it" />
</module>

很遗憾,这样做并没有解决问题任何人都可以向我建议任何其他尝试吗?

谢谢

安杰洛

最佳答案

GWT 模块的加载方式,之后定义的任何内容覆盖之前定义的内容,<inherits>被处理为就好像继承的模块被包含在适当的地方。

因此您应该移动您的 <property-provider> <inherits name="com.google.gwt.user.UserAgent"/> 之后行行。

关于java - GWT 2.4 IE8 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18637805/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com