* * .nocache.js查看查詢字符串參數以觸發加載您安裝在瀏覽器中的開發模式插件,因此它會連接回指定的DevMode應用程序。
當你不得不在頁面之間重定向,並且你希望它們都以開發模式或者網頁模式運行時,最簡單的辦法是調整參數(如果可能的話,使用現有的值而不是硬編碼)到!GWT.isProdMode()
:
if (!GWT.isProdModode()) {
// assumes 'url' doesn't contain a query-string yet
url += "?gwt.codesvr=" + Window.Location.getParameter("gwt.codesvr");
}
如果不使用查詢字符串自己,所以纔有望不斷與gwt.codesvr
參數存在或不存在,你可以使用UrlBuilder
使它更簡單:
UrlBuilder builder = Window.Location.createUrlBuilder();
builder.setPath(GWT.getHostPageBaseURL() + "UserRegistration.html")
//don't pass the history token around:
builder.setHash(null);
// builder.toString() will then keep the same query string.
它甚至沒有適應應用程序運行的當前「模式」,因爲它只是無條件地複製查詢字符串。
'GET.getHostPageBaseURL()'返回絕對URL,包括scheme,host:port。在'setPath()'中使用這個會導致格式不正確的URL。但是,如果您完全忽略調用'setPath()',則會假定頁面的當前URL,它適用於典型的GWT單頁web應用程序。 – spoulson