【问题标题】:Refer to css from jsp从jsp引用css
【发布时间】:2012-08-11 04:54:52
【问题描述】:

我在WebContent/WEB-INF/forms/login.jsp下有jsp页面-

<html>
<head>
<link rel="stylesheet" href=/Styles/Styles/Site.css" type="text/css" />
<title>Create new customer</title>
</head>
<body>
</body>
</html>

Site.css 位于 WebContent/Styles 。当我加载 login.jsp 时,我看到 css 不会影响 .如何正确写href?

【问题讨论】:

标签: html css jsp href


【解决方案1】:

你可以使用

<link rel="stylesheet" href="../../Styles/Site.css" type="text/css" />

或者如果你的页面在http://yoursite.com/path/to/WebContent/WEB-INF/forms/login.jsp,你可以使用

<link rel="stylesheet" href="/path/to/WebContent/Styles/Site.css" type="text/css" />

【讨论】:

  • 在 Java 中,WEB-INF 是一个受保护的目录。 ../../ 诡计不需要工作!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-06-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-12-25
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多