Relative path for static resources

549 Views Asked by At

I am using ff4j web library for toggling in my Java web application. The URL for the web console resolves to localhost:8443/bat/ff4j-console However static resources in the html resolve to localhost:8443/bat/static/images. How to find static resources at localhost:8443/bat/ff4j-console/static .

 In essence, how to use relative path. I have configured ff4j servlet in web.xml
1

There are 1 best solutions below

0
On

Could you please confirm that you use the 1.6 version. I put here a sample of XML definition (web.xml) as you mentionned it.

<!-- Embedded Console -->
<servlet>
    <servlet-name>ff4j-console</servlet-name>
    <servlet-class>org.ff4j.web.FF4jDispatcherServlet</servlet-class>
    <init-param>
        <param-name>ff4jProvider</param-name>
        <param-value>org.ff4j.sample.SimpleFF4jProvider</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>ff4j-console</servlet-name>
    <url-pattern>/ff4j-console/*</url-pattern>
</servlet-mapping>

Then please note that the URL MUST HAVE A SLASH at the end.

Your URL is not localhost:8443/bat/ff4j-console but localhost:8443/bat/ff4j-console/

This should resolve the static not found and display all pictures.

This a issue of Thymeleaf and definition in XML (look you put /*). If you have ideas you're welcome it's defined here https://github.com/clun/ff4j/blob/master/ff4j-web/src/main/java/org/ff4j/web/FF4jServlet.java#L172-L182