restlet 访问静态资源遇到的 404 问题

在访问静态资源是老是弹出这个错误

后台日志

信息: 2019-08-14        10:43:09        0:0:0:0:0:0:0:1 -       -       8080    GET     /resources/login.html   -       404     439     0       24
http://localhost:8080   Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36    -

解决方案  (如下代码中的红色字体 , 不要忘记协议):  

public class StaticResourceApplication extends Application {

    /**
     * 日志对象
     */
    private final Logger logger = LoggerFactory.getLogger(getClass());
    
    
    public StaticResourceApplication() {
        setName("静态资源");
//        component.getClients().add(Protocol.FILE);
        //this.getConnectorService().getClientProtocols().add(Protocol.FILE);
    }

    public Restlet createInboundRoot() {
        logger.debug("Create Inbound Root ... ");
        Directory dir = new Directory(getContext(),"file:///E:/workspaces/Demo/Resources/");
        dir.setListingAllowed(true);
        dir.setDeeplyAccessible(true);
        dir.setNegotiatingContent(true);
        return dir;
    }

}

猜你喜欢

转载自www.cnblogs.com/hi-gdl/p/11350805.html