javafx 2 webview custom url handler, funktioniert nicht mit relativer url

Ich habe eine einfache App mit Code:

webView.getEngine().load("classpath:data/index.html");

Benutzerdefinierter URLStreamHandler:

public class Handler extends URLStreamHandler {
    private final ClassLoader classLoader;

    public Handler() {
        this.classLoader = getClass().getClassLoader();
    }

    public Handler(ClassLoader classLoader) {
        this.classLoader = classLoader;
    }

    @Override
    protected URLConnection openConnection(URL u) throws IOException {
        URL resourceUrl = classLoader.getResource(u.getPath());
        if(resourceUrl == null)
            throw new IOException("Resource not found: " + u);

        return resourceUrl.openConnection();
    }
}

installiert von:

URL.setURLStreamHandlerFactory(protocol -> {
    if(protocol.equals("classpath")) {
        return new Handler();
    } else {
        return null;
    }
});

Es lädt data / index.html:

<!DOCTYPE html>
<html>
<head>
    <title>Test</title>
</head>
<body>
<div>Hello, World!!!</div>
<img src="download.jpg">
</body>
</html>

Im Ergebnis wird das Bild jedoch nicht angezeigt.

Was ist zu tun, damit WebView relative Links wie "download.jpg" auflösen kann?

Antworten auf die Frage(1)

Ihre Antwort auf die Frage