简体   繁体   English

将CSS文件链接到JSP的问题

[英]Issues Linking CSS File to JSP

I am trying to link a css to my jsp page but I keep getting a 404 page not found error. 我正在尝试将CS​​S链接到我的jsp页面,但是我不断收到404页面未找到错误。

href in the homepage.jsp: <link href="../resources/css/welcome.css" rel="stylesheet" /> 在homepage.jsp中的href: <link href="../resources/css/welcome.css" rel="stylesheet" />

file structure:
-->webapp
  -->img 
  -->resources
    -->css
      -->welcome.css
  -->WEB-INF
    -->views
      -->homepage.jsp

As you're using Spring MVC: 当您使用Spring MVC时:

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

If you hate JSTL, you can use the “page context” variable to get the resources like this : 如果您讨厌JSTL,则可以使用“页面上下文”变量来获取如下资源:

<link href="${pageContext.request.contextPath}/resources/css/welcome.css" rel="stylesheet" >

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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