JSP之后,如何在HTML中加载值?
我正在使用JSP练习HTML,我一直在做一些练习以使其陷入困境,但是我不知道如何从JSP返回后加载价值。
我只有2页的代码,html和jsp
html:
//var nombre = document.getElementById("nombre").value;
function siexiste (){
var nombre = document.getElementById("nombre").value;
//alert(nombre);
if (nombre === "") {
document.getElementById("name").style.visibility = "visible";
document.getElementById("nombre").style.visibility = "visible";
}
else{
document.getElementById("name").style.visibility = "hidden";
document.getElementById("nombre").style.visibility = "hidden";
}
}
</script>
</head>
<body onload='siexiste()'>
<form action="arttack.jsp">
<label id="name" for="nombre"> Tu nombre </label>
<input id="nombre" type="text" name="nombre" value=""/>
<br> <br> <label> Color fondo </label> <br>
<input id="fondo" type="text" name="fondo" value="" />
<br> <label> Color fuente </label> <br>
<input id="fuente" type="text" name="fuente" value=""/> <br> <br>
<br>
<input type="submit" value="Presiona" />
</form>
</body>
以及JSP:
<body style="background-color:<%=fondo%>;">
<h1 style="color:<%=fuente%>"><%=n%> </h1>
</body>
全部有效,但是我想在JSP之后回到HTML,我需要保存“ nombre”的值,以便保存标签“标签”名称“及其输入文本不会出现。 顺便说一句,我正在使用玻璃鱼。 如果您能为我提供帮助,我将非常感谢。 :)
I'm practicing HTML with JSP, i've been doing some exercises to steep up, but i don't have a idea how to load a value after returning from a JSP.
i have only 2 pages of code, the HTML and JSP
HTML:
//var nombre = document.getElementById("nombre").value;
function siexiste (){
var nombre = document.getElementById("nombre").value;
//alert(nombre);
if (nombre === "") {
document.getElementById("name").style.visibility = "visible";
document.getElementById("nombre").style.visibility = "visible";
}
else{
document.getElementById("name").style.visibility = "hidden";
document.getElementById("nombre").style.visibility = "hidden";
}
}
</script>
</head>
<body onload='siexiste()'>
<form action="arttack.jsp">
<label id="name" for="nombre"> Tu nombre </label>
<input id="nombre" type="text" name="nombre" value=""/>
<br> <br> <label> Color fondo </label> <br>
<input id="fondo" type="text" name="fondo" value="" />
<br> <label> Color fuente </label> <br>
<input id="fuente" type="text" name="fuente" value=""/> <br> <br>
<br>
<input type="submit" value="Presiona" />
</form>
</body>
and the JSP:
<body style="background-color:<%=fondo%>;">
<h1 style="color:<%=fuente%>"><%=n%> </h1>
</body>
all works, but i want to come back to the HTML after JSP, and I need the value of "nombre" to be saved so that the label "name" and its input text don't appear.
I am using glassfish by the way.
If you could help me with this, I would really appreciate it. :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将所有内容加载到同一JSP中。
因此,如果您没有加载值,则表格将显示。
如果您提交了该表格,它将隐藏起来和所示的值。
这样的事情:
You can load everything in the same JSP.
So if you don't have a value loaded, the form is gonna show.
And if you have submitted that form, it's gonna hide and the values shown.
Something like this: