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

Popular posts from this blog

python - How to add an model instance to a django queryset? -

Using Android Volley to post an array to PHP -

angularjs - No 'Access-Control-Allow-Origin' error from local domain to public API -