Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Springboot unable to load js files from resources folder

I have uploaded my project on the project to git https://github.com/gitekiras/spring-boot-gradle-mvc

What i am not able to get right is that i am not able to load the css and js from the resources folder.

When i put it in webapp folder, i am able to get every thing working but according to the tutorials, i should put them in the static folder in resources.

but when i do so i am not able to load the css and js on page.

Can any one say what i am missing ?

Also: when i see in browser logs - it shows that it is trying to find the js and css files as application/json. I am not sure what i have done wrong here.

like image 216
Ekansh Rastogi Avatar asked Mar 16 '26 14:03

Ekansh Rastogi


1 Answers

You explicitly overrode the default behavior by adding your own @EnableWebMvc - see Spring MVC auto-configuration. Remove the @EnableWebMvc (and also unneeded resource handler for /resources/**) and it will work.

like image 139
Roman Avatar answered Mar 19 '26 04:03

Roman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!