简体   繁体   中英

GWT - compile to html file

I'm new in using GWT.

When I heard about GWT I thought than I will be able to compile Java code to html+css+js files and can use it offline without any webserver. Now, when I'm reading how tos about starting with GWT I see that compiled GWT application has to be deployed before starting it in webbrowser.

Is any way to compile GWT to plain html files and run it in browser by simply clicking some html file?

Try adding the following to your gwt.xml :

<add-linker name='xsiframe' />

The reason is that files loaded from the filesystem are all treated as if they came from different origins , so it's really easy to be caught by the so-called same-origin policy .

By default (using the std linker), GWT outputs *.cache.html files that are loaded in an iframe , so, being from different origins, the code in the iframe cannot talk to the HTML host page .

Using the xsiframe linker (or the now-deprecated xs linker), GWT generates *.cache.js files that are loaded using script tags, which allows loading scripts cross-origins .

See https://developers.google.com/web-toolkit/doc/latest/FAQ_Server#What_is_the_Same_Origin_Policy,_and_how_does_it_affect_GWT ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM