Is there way for a GWT program to tell if it's in hosted or web mode?

前端 未结 2 1865
广开言路
广开言路 2021-02-09 00:02

I would like my GWT program to be able to determine whether it\'s in hosted mode or in web mode. Is there a way to do this?

Thanks!

相关标签:
2条回答
  • 2021-02-09 00:20

    GWT.isScript() returns true in non hosted mode and false in hosted mode.

    http://google-web-toolkit.googlecode.com/svn/javadoc/1.5/com/google/gwt/core/client/GWT.html#isScript()

    0 讨论(0)
  • 2021-02-09 00:22

    Be careful with this. You still can't run unemulated Java code in the statement.

    if(GWT.isScript()) {
      //some code not in the JRE emulation here
    }
    

    The example code will cause compile time problems.

    0 讨论(0)
提交回复
热议问题