Spring-boot serving content outside context root and getting content as resources -
Spring-boot serving content outside context root and getting content as resources -
i've added new resources handler "outside context root" next configureradapter:
@configuration public class dynamicassetsconfigurer extends webmvcconfigureradapter { @override public void addresourcehandlers(resourcehandlerregistry registry) { registry.addresourcehandler("/dynamicassets/**") .addresourcelocations("file:/var/dynamicassets/"); super.addresourcehandlers(registry); } }
handler works fine when making requests server, access content of "/dynamicassets/**" resources. can access "static assets" (assets directory within context root):
@inject private webapplicationcontext webcontext; public resource[] getstaticassetresources() { // returns array of servletresource objects homecoming webcontext.getresources( "/assets/*.*"); } public resource[] getdynamicassetresources() { // fails resources, because // dynamicassets not found context homecoming webcontext.getresources( "/dynamicassets/*.*"); }
how access files in "/dynamicassets/" servletresource objects ?
spring resources spring-boot
Comments
Post a Comment