JavaFX: in WebView img tag is not loading local images

泪湿孤枕 提交于 2019-12-06 10:06:48

Thank you guys for your help, I got the Following very simple solution

imgs += "<img src=\""+fs.toURI()+"\" width='50'>";

the image path must be converted to URI or URL to make the webView able to read it

You can try this:

URL url = getClass().getResource("Smiley.png");
File file = new File(url.getPath());

You probably need to read the file paths also via getClass().getResource():

    for (File fs : f.listFiles()) {
        imgs += "<img src=\"" + getClass().getResource(fs.getName()) + "\" width='50' />";
    }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!