Search code examples
javaspring-mvcjstl

JSTL c:url not working


I'm learning Spring MVC. My static resources are successfully mapped using spring taglib. But resources are not mapped if i use JSTL c taglib.

Project Structure

enter image description here

web.xml

enter image description here

spring-servlet.xml

enter image description here

main.css

h1{
    color:red;
}

welcome.jsp

enter image description here

output

enter image description here

Jquery and main.js is loaded with the spring taglib that's why h2 has body, but I don't understand why h1's color is not red?

05-May-2017 15:45:24.843 WARNING [http-nio-8080-exec-4] org.springframework.web.servlet.PageNotFound.noHandlerFound No mapping found for HTTP request with URI [/basic/public-resources/css/main.css] in DispatcherServlet with name 'dispatcher'

Solution

  • I found the solution. I changed

    <link rel="stylesheet" href='<c:url value="/public-resources/css/main.css" />'>
    

    to

    <link rel="stylesheet" href='<c:url value="/resources/css/main.css" />'>
    

    IntelliJ is giving me error that the directory is not resolved and the whole directory is red. but when deployed, it works.