GWT - did you forget to inherit a required module?

折月煮酒 提交于 2019-12-29 07:23:32

问题


In my GWT application, on the client side Java file, I have written a line to print the Locale:

System.out.println(Locale.getDefault());

Here Locale is an instance of java.util.Locale.

I'm getting an exception: 09:31:53.656 [ERROR] [stockwatcher] Line 167 No source code is available for type java.util.Locale; did you forget to inherit a required module?

Surprisingly, in this class I've also used java.util.ArrayList and java.util.Date but I did not get any exception for those classes.

What am i doing wrong here?


回答1:


The client-side of GWT does not have access to the whole Java API. Java.util.Locale is one of them. You can't use or even import it on the client-side. But you can definitely use it on the server-side of GWT. You can find the list of classes that can be used at client-side here.




回答2:


In addition to information in RAS's answer, you could use GWT's class LocaleInfo to obtain information about available locales or current locale.

System.out.println(LocaleInfo.getCurrentLocale());

Hope this helps!



来源:https://stackoverflow.com/questions/5575909/gwt-did-you-forget-to-inherit-a-required-module

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!