由于就是官方的实例照搬了一下,简单尝试没有问题。就先把代码贴出来了。
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();
}
}