Html 如何在 JSP 中使用 Twitter 引导程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22230748/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to use twitter bootstrap with JSP
提问by user3279337
I can't understand why my jsp page don't huck up bootstrap styles.
我不明白为什么我的 jsp 页面不支持引导程序样式。
My hello.jsp
我的你好.jsp
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap 101 Template</title>
<link href="<c:url value="/bootstrap/css/bootstrap.min.css"/>" rel="stylesheet">
</head>
<body>
<h1>Hello, world!</h1>
<div class="btn-group">
<button type="button" class="btn btn-default">Left</button>
<button type="button" class="btn btn-default">Middle</button>
<button type="button" class="btn btn-default">Right</button>
</div>
<script src="<c:url value="/bootstrap/js/bootstrap.min.js"/>"></script>
</body>
</html>
My directory project structure:
我的目录项目结构:
Any ideas how to properly add bootstrap?
任何想法如何正确添加引导程序?
采纳答案by Dramorian
If you are using Springs framework you can add these line in dispatcher-servlet.xml
如果您使用的是 Springs 框架,则可以在 dispatcher-servlet.xml 中添加这些行
<mvc:resources mapping="/bootstrap/**" location="/resources/" />
回答by Darren
Try using https://github.com/Mrdigs/Bootstrap.jsp
尝试使用https://github.com/Mrdigs/Bootstrap.jsp
Its an open source JSP taglib designed to make working with Bootstrap and JSP simple, quick, and rewarding.
它是一个开源的 JSP 标记库,旨在使使用 Bootstrap 和 JSP 变得简单、快速和有益。
回答by blackwingman
It's also like my problem while using this BootStrap thing. in your folder-tree like that you wrote
这也像我在使用 BootStrap 时遇到的问题。在你写的文件夹树中
value="/bootstrap/css/bootstrap.min.css"
try
尝试
value="bootstrap/css/bootstrap.min.css"
without using '/'
不使用“/”
回答by heronsanches
Another observation is that if you is using 'Eclipse", you must "refresh" your project after adding anything.
Ex.:
If you add some .js, you must "refresh" your project in eclipse
If you add some .css, you must "refresh" your project in eclipse
另一个观察结果是,如果您使用的是“Eclipse”,则必须在添加任何内容后“刷新”您的项目。
例如:
如果您添加了一些 .js,您必须在 Eclipse 中“刷新”您的项目
如果您添加一些 .css,您必须在 eclipse 中“刷新”你的项目
回答by Jose Luis Garcia
spring mvc normaly load any source of external html libraries from the resource folder, located on your src distribution src->main->webapp->resource, Paste all your js, css there and link it to your jsp with
spring mvc 通常从位于您的 src 发行版 src->main->webapp->resource 上的资源文件夹中加载任何外部 html 库的源,将所有 js、css 粘贴到那里并将其链接到您的 jsp
<link href="resources/css/yourResource.css" rel="stylesheet">