GWT属性可以从服务器使用吗? [英] Can GWT Properties be used from the server?

查看:148
本文介绍了GWT属性可以从服务器使用吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用GWT RPC与App Engine servlet交谈的GWT应用程序。我想使用服务器上.properties文件中定义的常量。这是可能的吗?

I have a GWT app that uses GWT RPC to talk to App Engine servlets. I would like to use constants defined in a .properties file on the server. Is that possible?

推荐答案

在您使用的客户端中启用.properties

To enable .properties in client you use

GWT.create(file_name.properties);

但是这种组合在服务器端不起作用,因为它只能在客户端使用,你会得到这个错误:

But this combination don't work on server-side, cause it's only availible on client-side, you'll get this error:

GWT.create() is only usable in client code!  It cannot be called, for example, from server code.

但是,我想,您可以使用标准方式处理.properties文件,如

But, I suppose, you can use standard approach of processing .properties files like

Properties props = new Properties();
props.load(new FileInputStream("file_name.properties"));

并使用相对路径,而不是绝对路径。它应该适用于GAE

And use a relative path, not an absolute path. It should work on GAE

这篇关于GWT属性可以从服务器使用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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