Servlet 3.0 web-fragment serve static content

173 Views Asked by At

I have a web-fragment containing swagger-ui used by many web projects (WARs). The static content of the swagger-ui resides in META-INF/resources. Some of the web projects only provide a REST-API and have no own UI. For this kind of projects the web-fragment works, because the static content is served under ${CONTEXT-ROOT}/*. But for projects with a custom UI served under ${CONTEXT-ROOT}/* I do not know how to serve the swagger-ui for example under ${CONTEXT-ROOT}/api/*.

Is there any possibility to change where static content of a web-fragment is served in the main web project?

1

There are 1 best solutions below

0
On

It is not really a solution, rather a workaround. In the parent web.xml I can remap the servlet name of the web-fragment like this:

<servlet-mapping>
    <servlet-name>swagger</servlet-name>
    <url-pattern>/api/api/*</url-pattern>
</servlet-mapping>