Spring 4.3.0 + Tomcat : "Failed to load resource " message for static files -
i using spring mvc angularjs frontend. unfortunately, can't see static files when deploying in tomcat.
my aim deploy angularjs frontend files , spring backend stuff single war file deployment in tomcat.
i don't want use jsp nor spring xml files.
this structure of eclipse maven folder :
my index.html file contains following entries :
<script type="text/javascript" src="bower_components/angular/angular.js"></script> <script src="bower_components/angular-route/angular-route.js"></script> <script src="bower_components/angular-xeditable/dist/js/xeditable.js"></script> <script src="bower_components/angular-resource/angular-resource.js"></script> <script src="js/app.js"></script> <script src="js/controllers.js"></script> <script src="js/services.js"></script> <link href="bower_components/angular-xeditable/dist/css/xeditable.css" rel="stylesheet"> <link href="bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
my springconfig.java looks :
@override public void addresourcehandlers(resourcehandlerregistry registry) { registry.addresourcehandler("/bower_components/**").addresourcelocations("/bower_components").setcacheperiod(3600); registry.addresourcehandler("/js/**").addresourcelocations("/js"); } @override public void configuredefaultservlethandling(defaultservlethandlerconfigurer configurer) { configurer.enable(); }
i hope can me out !
i think issue slashes. try this:
@override public void addresourcehandlers(resourcehandlerregistry registry) { registry.addresourcehandler("bower_components/**").addresourcelocations("/bower_components/").setcacheperiod(3600); registry.addresourcehandler("js/**").addresourcelocations("/js/"); }
if doesn't work, may have fiddle it. no 1 knows why that, unfortunately url path pattern matching has been 1 of inconsistent , buggiest aspects of spring mvc years.
Comments
Post a Comment