I am new to Spring MVC and i am having a problem with CSS. When the URL ends with slash CSS does not work.
link goes like this
<link rel="stylesheet" href="themes/style.css">
mvc:resources mapping
<mvc:resources mapping="/themes/**" location="/WEB-INF/themes/"/>
and requestMapping goes like this
@RequestMapping("/login")
public ModelAndView loginPage() {
ModelAndView model = new ModelAndView("login");
return model;
}
So the problem is when i enter a URL like ../login
the css loads normally, but when i enter ../login/
with ending slash, then the css does not load.
Well there are many similar questions in here, but none of them is for Spring MVC.
it will work 100%
step 1
setp 2
add a slash after value
step 3
add your style sheet like this
Instead of
try this:
When you use
href="themes/style.css"
then for url like:.../login/
the request url for css file looks like:which is incorrect. When you use
href="/themes/style.css"
then it always should result with:Update:
If it is jsp page, then add
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
on top of the page and change:into