简体   繁体   English

引导程序不适用于 jsp

[英]bootstrap doesn't work with jsp

I am try connect min lib css bootstrap for my jsp page.我正在尝试为我的 jsp 页面连接 min lib css bootstrap。 But nothing happened.但什么也没发生。 My proposal:jsp page:我的建议:jsp 页面:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ page session="false"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../css/bootstrap.min.css">
<script src="../../js/bootstrap.min.js"></script>
</head>
<body>

<h3>Tests List</h3>
<button type="submit" class="btn btn-info">
    <span class="glyphicon glyphicon-search"></span> Search
</button>
<c:if test="${!empty listTests}">
    <table class="table table-striped">
        <thead>
            <tr>
                <th width="25">Test ID</th>
                <th width="80">Test Name</th>
                <th width="80">Test Author</th>
                <th width="120">Test Description</th>
                <th width="60">Test IsFree</th>
                <th width="120">Test Comment to Admin</th>
                <th width="120">Test Section</th>
                <th width="120">Test Status</th>
                <th width="60">Review</th>
                <th width="60">Delete</th>
            </tr>
        </thead>
        <c:forEach items="${listTests}" var="test">
            <tr>
                <td>${test.id}</td>
                <td>${test.name}</td>
                <td>${test.author}</td>
                <td>${test.description}</td>
                <td>${test.isFree}</td>
                <td>${test.commentToAdmin}</td>
                <td>${test.section}</td>
                <td>${test.status}</td>
                <td><a href="<c:url value='/tests/review/${test.id}' />">Review</a></td>
                <td><a href="<c:url value='/tests/remove/${test.id}' />">Delete</a></td>
            </tr>
        </c:forEach>
    </table>
</c:if>
</body>
</html>

My folders hierarchy:我的文件夹层次结构:

folders文件夹

How you can see - in code I connected css and js file.你怎么看 - 在代码中我连接了 css 和 js 文件。 But there is result which I have(yep, info I loading with DB): result但是我得到了结果(是的,我用数据库加载的信息):结果

Try to use an absolute reference to the files. 尝试对文件使用绝对引用。

<link rel="stylesheet" href="/css/bootstrap.min.css">
<script src="/js/bootstrap.min.js"></script>

Instead of pointing from relative path of your JSP, please use absolute paths from the root of your project ie from webapp . 而不是从JSP的相对路径指向,而是从项目的根目录(即webapp使用绝对路径。

<link rel="stylesheet" href="/css/bootstrap.min.css">
<script src="/js/bootstrap.min.js"></script>

In JSP you should add context path to make it work:在 JSP 中,您应该添加上下文路径以使其工作:

<link rel="stylesheet" href="<%=request.getContextPath()%>/css/bootstrap.min.css">

<script src="<%=request.getContextPath()%>/js/bootstrap.min.js"></script>

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

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