【问题标题】:JSP unable to detect Bootstrap Spring MVCJSP 无法检测到 Bootstrap Spring MVC
【发布时间】:2016-09-26 07:10:12
【问题描述】:

我一直在努力将 Bootstrap CSS 文件包含到我的文件中。我的代码sn-p如下:

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-
1">
    <link rel="stylesheet"
          href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" type="text/css"> <!--Works fine now, but not with local path -->
    <title>Welcome</title>
</head>
<body>
<section>
    <div class="jumbotron">
        <div class="container">
            <h1> Hello </h1>
            <p> world </p>
        </div>
    </div>
</section>
</body>
</html>

这很好用,并且 Bootstrap 显示得很好。但是,我希望包含本地化文件。当我将代码头部的 link 更改为 &lt;link rel="stylesheet" href="resources/bootstrap.css" type="text/css"&gt; 时,引导程序消失。

只是为了确保并说服您 bootstrap.css 确实存在于 resources/bootstrap.css 我在代码顶部添加了 &lt;%@ include file="/resources/bootstrap.css"%&gt; 并它实际上向我展示了文件的全部内容。

我错过了什么?我该如何解决这个问题?

【问题讨论】:

  • PS:NONE 关于 SO 的现有答案对我有帮助。有几个问题询问同一件事,但没有一个有效。

标签: html twitter-bootstrap jsp spring-mvc


【解决方案1】:

如果你有这个项目结构(我建议试试这个,因为资源文件夹内容不用于静态网页内容):

|_webapp
       |_css
             |_bootstrap.css

你可以通过

加载css

&lt;link rel="stylesheet" href="&lt;%=request.getContextPath()%&gt;/css/bootstrap.css" type="text/css"&gt;

【讨论】:

  • 在 webapps 内部,resources->styles->bootstrap.css
  • 如果这个 bootstrap 文件存在,你检查过浏览器开发者选项-sources-your_app 吗?!
猜你喜欢
  • 1970-01-01
  • 2016-06-15
  • 1970-01-01
  • 2015-05-28
  • 2013-10-05
  • 2011-06-23
  • 1970-01-01
  • 1970-01-01
  • 2015-10-06
相关资源
最近更新 更多