How to reach css and image files from the html page loaded by javafx.scene.web.WebEngine#loadContent?

后端 未结 4 697
旧时难觅i
旧时难觅i 2020-12-11 16:19

I have a String HTML content which is loaded into webEngine by loadContent() method. I have also some css and image files used in this page. Althou

4条回答
  •  难免孤独
    2020-12-11 17:03

    I just found out that using the tag in the HTML also does the trick:

    
        
            The slash at the end of the href is important!
            
        
        
            
        
    
    

    If you load the above code via engine.loadContent(String) then image.png will be loaded from /absolute/path/to/your/docroot/image.png.

    This method is easier if you need to load multiple resources since you only have to specify the absolute path at a single place.

    This has been tested with WebView of Java 8u25.

提交回复
热议问题