在訪問靜態資源是總是彈出這個錯誤html
後臺日誌字體
信息: 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 -
解決方案 (以下代碼中的紅色字體 , 不要忘記協議): this
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; } }