You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Spring框架/Maven环境下Bootstrap使用异常求助

Fixing Your Bootstrap 4 Navbar Issues

Hey there, I can spot a couple of clear issues in your code that are keeping your Bootstrap navbar from working as expected—let’s break them down and fix things step by step:

Key Problems in Your Code

  • Bootstrap Version Class Mismatch: You’re using Bootstrap 4 (beta 3), but you’ve added the Bootstrap 3 class navbar-default to your nav element. Bootstrap 4 completely overhauled navbar styling classes, so this old class won’t apply any styling here.
  • Invalid HTML Syntax: There’s a random $$ right after closing the .container-fluid div—this is invalid code that will break your page’s structure and prevent proper rendering.
  • (Optional) Broken Image Path: Your brand image uses src="...", which won’t load any actual image. This is a secondary issue, but worth fixing once the navbar itself works.

Corrected Full Code

Here’s the fixed version of your JSP with all issues resolved:

<%-- Created by IntelliJ IDEA. User: reaganyuan Date: 1/6/18 Time: 3:09 PM To change this template use File | Settings | File Templates. --%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" integrity="sha384-Zug+QiDoJOrZ5t4lssLdxGhVrurbmBWopoEl+M6BdEfwnCJZtKxi1KgxUyJq13dy" crossorigin="anonymous">
    <title>Hello, world!</title>
</head>
<body>
<nav class="navbar navbar-light bg-light"> <!-- Replaced Bootstrap 3 class with Bootstrap 4 compatible classes -->
    <div class="container-fluid">
        <div class="navbar-header">
            <a class="navbar-brand" href="#">
                <img alt="Brand" src="your-image-path-here.png"> <!-- Replace with actual image path -->
            </a>
        </div>
    </div> <!-- Removed invalid $$ syntax -->
</nav>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/js/bootstrap.min.js" integrity="sha384-a5N7Y/aK3qNeh15eJKGWxsqtnX/wWdSZSKp+81YjTmS15nvnvxKHuzaWwXHDli+4" crossorigin="anonymous"></script>
</body>
</html>

Quick Extra Tips

  • For a dark-themed navbar, swap navbar-light bg-light with navbar-dark bg-dark (or any other Bootstrap background utility class like bg-primary for a colored header).
  • If you want your brand image to show up, replace your-image-path-here.png with the actual relative or absolute path to your image file.

内容的提问来源于stack exchange,提问作者reagan yuan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 07:36:16