模态窗体不显示
Modal Form not showing up
我有一个 .jsp 文件,其中有一个 header,其中包含一个 ID 为“modalFormButton”的按钮,按下该按钮时必须显示模态表单。模态形式的代码在另一个 .jsp 文件中,所以我动态添加它。我已经检查过它是否成功调用了包含上述内容的文件,但它不显示表单。我也尝试将表单代码放在同一个文件中。jsp 我从中调用它,但它也不起作用。
PS:模态表单包含在 ID 为“agregarClienteModal”的 div 中。另外,我正在使用 Bootstrap.
.jsp 主文件:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous">
<title>JSP Page</title>
</head>
<body>
<header class = "py-2 bg-info text-white">
<div>
<h1>
Clients
</h1>
<button type = "button" id = "modalFormButton" class="btn btn-primary btn-block data-toggle="modal" data-target="#agregarClienteModal">
Agregar Cliente
</button>
</div>
<jsp:include page="addClientModalForm.jsp"/>
</header>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/js/bootstrap.bundle.min.js" integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf" crossorigin="anonymous"></script>
</body>
</html>
模态形式代码:
<div class="modal fade" id="agregarClienteModal">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header bg-info text-white">
<h5 class="modal-title">Agregar Cliente</h5>
<button class="close" data-dismiss="modal">
<span>×</span>
</button>
</div>
<form action="${pageContext.request.contextPath}/servlet?accion=insertar"
method="POST" class="was-validated">
<div class="modal-body">
<div class="form-group">
<label for="nombre">Nombre</label>
<input type="text" class="form-control" name="nombre" required>
</div>
<div class="form-group">
<label for="apellido">Apellido</label>
<input type="text" class="form-control" name="apellido" required>
</div>
<div class="form-group">
<label for="email">Email</label>
<input type="email" class="form-control" name="email" required>
</div>
<div class="form-group">
<label for="telefono">Teléfono</label>
<input type="tel" class="form-control" name="telefono" required>
</div>
<div class="form-group">
<label for="saldo">Saldo</label>
<input type="number" class="form-control" name="saldo" required step="any">
</div>
</div>
<div class="modal-footer">
<button class="btn btn-primary" type="submit">Guardar</button>
</div>
</form>
</div>
</div>
</div>
data-
属性在 Bootstrap 中更改为 data-bs-
5...
<div>
<h1> Clients </h1>
<button type="button" id="modalFormButton" class="btn btn-primary btn-block" data-bs-toggle="modal" data-bs-target="#agregarClienteModal"> Agregar Cliente </button>
</div>
我有一个 .jsp 文件,其中有一个 header,其中包含一个 ID 为“modalFormButton”的按钮,按下该按钮时必须显示模态表单。模态形式的代码在另一个 .jsp 文件中,所以我动态添加它。我已经检查过它是否成功调用了包含上述内容的文件,但它不显示表单。我也尝试将表单代码放在同一个文件中。jsp 我从中调用它,但它也不起作用。
PS:模态表单包含在 ID 为“agregarClienteModal”的 div 中。另外,我正在使用 Bootstrap.
.jsp 主文件:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous">
<title>JSP Page</title>
</head>
<body>
<header class = "py-2 bg-info text-white">
<div>
<h1>
Clients
</h1>
<button type = "button" id = "modalFormButton" class="btn btn-primary btn-block data-toggle="modal" data-target="#agregarClienteModal">
Agregar Cliente
</button>
</div>
<jsp:include page="addClientModalForm.jsp"/>
</header>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/js/bootstrap.bundle.min.js" integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf" crossorigin="anonymous"></script>
</body>
</html>
模态形式代码:
<div class="modal fade" id="agregarClienteModal">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header bg-info text-white">
<h5 class="modal-title">Agregar Cliente</h5>
<button class="close" data-dismiss="modal">
<span>×</span>
</button>
</div>
<form action="${pageContext.request.contextPath}/servlet?accion=insertar"
method="POST" class="was-validated">
<div class="modal-body">
<div class="form-group">
<label for="nombre">Nombre</label>
<input type="text" class="form-control" name="nombre" required>
</div>
<div class="form-group">
<label for="apellido">Apellido</label>
<input type="text" class="form-control" name="apellido" required>
</div>
<div class="form-group">
<label for="email">Email</label>
<input type="email" class="form-control" name="email" required>
</div>
<div class="form-group">
<label for="telefono">Teléfono</label>
<input type="tel" class="form-control" name="telefono" required>
</div>
<div class="form-group">
<label for="saldo">Saldo</label>
<input type="number" class="form-control" name="saldo" required step="any">
</div>
</div>
<div class="modal-footer">
<button class="btn btn-primary" type="submit">Guardar</button>
</div>
</form>
</div>
</div>
</div>
data-
属性在 Bootstrap 中更改为 data-bs-
5...
<div>
<h1> Clients </h1>
<button type="button" id="modalFormButton" class="btn btn-primary btn-block" data-bs-toggle="modal" data-bs-target="#agregarClienteModal"> Agregar Cliente </button>
</div>