Reputation: 73
Including floder structure
I 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
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>
<servlet-name>Resource Servlet</servlet-name>
<servlet-class>org.springframework.js.resource.ResouceServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Resource Servlet</servlet-name>
<url-pattern>/resources/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.css</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.js</url-pattern>
</servlet-mapping>
Upvotes: 3
Views: 9611
Reputation: 73
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
Upvotes: 1