如何在提交后隐藏表单?(Java,Jsp)



我是新来的。我需要了解更多关于jsp页面的信息。我想把表单隐藏在按钮"之后;提交";在此Jsp页面中,按下以查看填充结果表单。
当我按";crea contatto";它给我看表格和填写表格的结果。我怎么看只有结果?

非常感谢!

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Aggiunto nuovo contatto</title>
</head>
<body>
<!-- header -->
<jsp:include page="header.jsp" />

<h1>Aggiungi un nuovo contatto</h1>
<form method="POST" action="AggiungiPersona.do">

Id: <input type="number" size="40 maxlength=40" name="id" /><br />
Nome: <input type="text" size="40 maxlength=40" name="nome" /><br />
Cognome: <input type="text" size="40 maxlength=40" name="cognome" /><br />
Anni: <input type="number" size="40 maxlength=40" name="anni" /><br />
Sesso: <input type="text" size="40 maxlength=40" name="sesso" /><br />
Indirizzo: <input type="text" size="40 maxlength=40" name="indirizzo" /><br />
Numero di telefono: <input type="text" size="40 maxlength=40"
name="numTel" /><br /> Email: <input type="text"
size="40 maxlength=40" name="email" /><br /> <br> <input
type="submit" value="crea contatto">

</form>

<c:choose>



<c:when test="${error==true}">
<h1>Errore</h1>
<p>Attenzione! Inserire un'età compresa tra 0 e 100.</p>
<br>
<br>
<a href="./aggiungiPersona.html">Torna al form</a>
<br>
</c:when>
<c:when test="${error2==true}">
<h1>Errore</h1>
<p>Attenzione! L'id che si sta cercando di inserire è già
presente in database. Scegliere un id diverso.</p>
<br>
<br>
<a href="./aggiungiPersona.html">Torna al form</a>
<br>
</c:when>
<c:when test="${error3==true}">
<h1>Errore</h1>
<p>Attenzione! Il valore associato a "sesso" può essere solo "m",
"M", "f", "F".</p>
<br>
<br>
<a href="./aggiungiPersona.html">Torna al form</a>
<br>
</c:when>

<c:when test="${error4==true}">
<h1>Errore</h1>
<p>Attenzione! Il numero di telefono può contenere solo numeri.</p>
<br>
<br>
<a href="./aggiungiPersona.html">Torna al form</a>
<br>
</c:when>
<c:when test="${error5==true}">
<h1>Errore</h1>
<p>Attenzione! L'email deve contenre il simbolo '@'.</p>
<br>
<br>
<a href="./aggiungiPersona.html">Torna al form</a>
<br>
</c:when>
<c:when test="${successo==true}">
<h1>Aggiunto nuovo contatto!</h1>
<p>
Id:
<% String id = request.getParameter("id"); out.print(id); %>
<br /> Nome:
<% String nome = request.getParameter("nome"); out.print(nome); %>
<br /> Cognome:
<% String cognome = request.getParameter("cognome"); out.print(cognome); %>
<br /> Età:
<% String anni = request.getParameter("anni"); out.print(anni); %>
<br /> Sesso:
<% String sesso = request.getParameter("sesso"); out.print(sesso); %>
<br /> Indirizzo:
<% String indirizzo = request.getParameter("indirizzo"); out.print(indirizzo); %>
<br /> Numero di telefono:
<% String numTel = request.getParameter("numTel"); out.print(numTel); %>
<br /> Email:
<% String email= request.getParameter("email"); out.print(email); %>
<br />
</p>


</c:when>

<c:otherwise>
<br>
<a href="./index.jsp">Torna alla HomePage</a>
<br>
</c:otherwise>
</c:choose>
</body>
</html>

您可以使用<c:if>测试来查看是否要隐藏它。

例如:

<c:if test="${id} ne null">
<form>
</form>
</c:if>

最新更新