0

我尝试从 RESTFul 服务访问本地文件。有没有办法获得正在运行的服务的真实路径?(就像我们可以在 servlet 中做的那样)

服务器:glassfish 3.0.1 IDE:Eclipse Helios

谢谢

4

2 回答 2

6

您将哪个框架用于 REST Web 服务?
您可以通过以下方式获得泽西岛的真实路径:

@Context ServletContext context //you can specify in your method argument
String realPath = context.getRealPath("/");

想想会帮助你。

于 2010-09-25T07:46:49.993 回答
0

代码:

@Context ServletContext context;//you can specify this above method as annotation

String realPath = context.getRealPath("/");
于 2015-10-14T10:07:26.377 回答