【发布时间】:2014-08-30 09:06:13
【问题描述】:
我的应用程序中有 Restlet 服务器,如果我在浏览器中打开服务器地址,则服务器应返回某个文件夹中的文件列表,如果用户单击该文件,则应下载该文件。
我看了这个tutorial。第 6 部分服务静态文件。这是这段代码:
public static final String ROOT_URI = "file:///c:/restlet/docs/api/";
[...]
// Create a component
Component component = new Component();
component.getServers().add(Protocol.HTTP, 8182);
component.getClients().add(Protocol.FILE);
// Create an application
Application application = new Application() {
@Override
public Restlet createInboundRoot() {
return new Directory(getContext(), ROOT_URI);
}
};
// Attach the application to the component and start it
component.getDefaultHost().attach(application);
component.start();
但如果我在 URI 中使用例如 file:///sdcard/,那么如果我在浏览器中打开地址,我会得到 p>
Not Found
The server has not found anything matching the request URI
You can get technical details here.
Please continue your visit at our home page.
怎么了?如何使用 Restlet 返回文件列表?
【问题讨论】:
标签: java android restlet restlet-2.0