如何将 JSTL 添加到 Bootstraped jsp 文件?

问题描述 投票:0回答:0

我已经使用 jsp 和 servlets 创建了一个 maven 项目。我的项目运行良好,所有字段都已成功存储到数据库中。但是我想在我的 jsp 文件中显示它是高度自举的。而我做不到。谁能帮我将存储在数据库中的数据显示到我的 jsp 文件中。

这是我的dashboard.jsp 文件,我登录成功后到达的地方。我想在注册该特定会话时动态显示存储在数据库中的用户名。我还编写了一种方法来查找也存储在数据库中的用户的更新余额。在我的仪表板中,我想显示该余额。我在我的 pom.xml 文件中添加了“jstl-1.2”maven 依赖项。请帮我动态显示我的字段。

Dashboard.jsp 文件:

<%@page import="java.util.jar.Attributes.Name"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"
        integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">

    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.2.0/css/all.css"
        integrity="sha384-hWVjflwFxL6sNzntih27bfxkr27PmbbK/iSvJ+a4+0owXq79v+lsFkW54bOGbiDQ" crossorigin="anonymous">

<title>Insert title here</title>
</head>
<body>

     <% 
     
     response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
     
     if(session.getAttribute("user")==null){
         response.sendRedirect("login.jsp");
     }
         
    %>

    <nav class="navbar navbar-expand-sm navbar-dark bg-dark">
        <div class="container">

            <div class="collapse navbar-collapse" id="mobile-nav">
                <ul class="navbar-nav mr-auto">
                    <li class="nav-item">
                        <a class="nav-link" href="dashboard.jsp">
                            Dashboard
                        </a>
                    </li>
                </ul>
                
                <form action="/logout">

                <ul class="navbar-nav ml-auto">
                   
                    <li class="nav-item">
                        <a class="nav-link" href="login.jsp">
                            Logout
                        </a>
                    </li>
                </ul>
                
                </form>
            </div>
        </div>
    </nav>
    

    <div class="projects">
        <div class="container">
            <div class="row">
                <div class="col-md-12">
                    <h1 class="display-4 text-center">Personal Bank</h1>
                    
                    <div class="card text-center">
                        <div class="card-header bg-warning text-white">
                            <h4>Welcome to your persona bank</h4>
                            <h1>Name</h1>  <!-- want to display name here -->
                        </div>
                    </div>
                    

                    <!-- Project Item Component -->
                    <div class="container">
                        <div class="card card-body bg-light mb-3">
                            <div class="row">
                                
                                <div class="col-lg-4 col-md-3 col-6 text-center">
                                    <h3>Current Balance</h3>
                                    <h1>Rs. 27000</h1>  <!-- want to display balance here -->
                                </div>
                                <div class="col-md-4 col-12 d-lg-block">
                                    <ul class="list-group">
                                        <a href="credit.jsp">
                                            <li class="list-group-item board text-success">
                                                <i class="fa fa-flag-checkered pr-1"> Credit </i>
                                            </li>
                                        </a>
                                        <a href="debit.jsp">
                                            <li class="list-group-item update text-info">
                                                <i class="fa fa-edit pr-1"> Debit </i>
                                            </li>
                                        </a>
                                        
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div>
                    <button class="btn btn-info"><a href="history.jsp" style="color:white ;"> Transaction History </a></button>
                    </div>
                    <!-- End of Project Item Component -->

                </div>
            </div>
        </div>
    </div>
    
    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
        integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
        crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"
        integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"
        crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"
        integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T"
        crossorigin="anonymous"></script>

</body>
</html>

数据库名称:交易

表名:注册用户

fields : name varchar, email varchar, gender varchar, dob varchar, address varchar, password varchar

下面给出的是我的maven项目的文件结构。

java jsp servlets jdbc jstl
© www.soinside.com 2019 - 2024. All rights reserved.