简体   繁体   中英

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

在此处输入图片说明

web.xml

在此处输入图片说明

spring-servlet.xml

在此处输入图片说明

main.css

h1{
    color:red;
}

welcome.jsp

在此处输入图片说明

output

在此处输入图片说明

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'

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM