读书人

Restlet2.0学习资料路径访问

发布时间: 2012-07-19 16:02:20 作者: rapoo

Restlet2.0学习——文件路径访问
由于就是官方的实例照搬了一下,简单尝试没有问题。就先把代码贴出来了。

public class DirStartRun {/** * web browser input:http://localhost:8182/ * @param args * @throws Exception */public static void main(String[] args) throws Exception {// URI of the root directory.   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();  }}

读书人网 >软件架构设计

热点推荐