在JSP中如何响应按钮事件

来源:百度知道 编辑:UC知道 时间:2024/05/16 11:02:18
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.util.*" %>
<html>
<head>
<title>无标题文档</title>
</head>
<body>
<form action="tijiao.jsp" method="post" name="form1" id="form1" >
<p align="center" >留言板</p>
<div align="center">姓名:
<input type="text" name="textfield1" />
<br/>
标题:
<input type="text" name="textfield2"/>
<br />
留言: 
<textarea name="textarea" cols="20" rows="6"></textarea>
<br />
</div>
<div align="center">
<input type="submit" name="button" value="提交" />
<input type="submit"

如果你确实要用jsp来做,只能告诉你没办法。因为jsp在完成这个页面后,已经和你的浏览器断开了连接,所以,除非你再次发出请求,否则重建连接。

你可以将它们改成
<input type="submit" name="submit" value="提交" />
<input type="button" name="show" value="查看留言" onclick="location.replace("tijiao.jsp?it=show")"/>
<input type="reset" name="reset" value="重置" />

利用参数it判断要做什么操作。

哈哈搞笑~~飘过!!大哥你不适合学JAVA 应该去学.net

我也遇到相同问题,请问楼主如何解决的?