Unable to read files from directories other that /src/main/resources
See original GitHub issueI ran into this issue today when I was trying to add a css file that resided in my java project that I’m using j2html in. I was trying to do this using the following code.
Tag css = styleWithInlineFile("style.css");
However, css was continually being set to null
. Looking through the code, I think I see why. In InlineStaticResource.java
, when the getFileAsString
method is called, the file path is constructed using InlineStaticResource.class.getResource(path)
. However, I believe this method is constructing and incorrect file path. From how I understand the line above to work, it’s basically only looking in the directory of InlineStaticResource.java
and below. Which means j2html effectively can’t see any files outside of this directory.
I’m using java 8 inside eclipse along with Maven.
Please let me know if my understanding is correct or if I should be able to add a css file given the current code.
Thanks!
Issue Analytics
- State:
- Created 8 years ago
- Comments:9 (5 by maintainers)
Top GitHub Comments
@mrtinkz, @austinlostinboston What do you think about #50 ?
Try it out in
if you haven’t 😃