有没有办法确定GWT代码是否在开发模式下运行? [英] Is there a way to determine if GWT code is running in development mode?

查看:91
本文介绍了有没有办法确定GWT代码是否在开发模式下运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个GWT应用程序,并希望根据代码是以开发模式运行还是在生产环境中进行分支。

I'm working on a GWT application and would like to branch some logic based on whether the code is running in development mode or is live in production.

例如,当代码需要进行AJAX调用时,我们希望根据模式设置URL。

For example, when the code needs to make an AJAX call we would like to set the URL depending on mode.

推荐答案

GWT> = 2.1.0

GWT >= 2.1.0

boolean isDevelopmentMode() {
    return !GWT.isProdMode() && GWT.isClient();
}

GWT < 2.1.0

GWT < 2.1.0

boolean isDevelopmentMode() {
    return !GWT.isScript() && GWT.isClient();
}

这篇关于有没有办法确定GWT代码是否在开发模式下运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆