ShasiSekar ShasiSekar - 1 year ago 135
CSS Question

Spring MVC CSS and JS not loading

Including floder structure

enter image description hereI am developing a web application in Spring MVC. I have issues loading CSS and JS files in JSP.

I googled for hours and tried all options, but not succeeded.
Here is what i did

  1. tried to load as normal web app giving relative path

  2. tried including mvc:resources

  3. tried loading through Resource Servlet even then nothing worked.

All three were tried separately
I am wondering what had i missed.

traditional link for #1

<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">

No changes done in mvc-config or web.xml

App Config for #2

<mvc:resources mapping="/resources/**" location="/resources/"/>

Web XML for #3

<servlet-name>Resource Servlet</servlet-name>
<servlet-name>Resource Servlet</servlet-name>

enter image description here

Answer Source

this post helped me to resolve the issue.

How to handle static content in Spring MVC?

But still wondering why my actions were not helpful

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download