
这个是主页面

主页面点击修改跳转到第二张图片那个页面,通过修改(也可不修改,用户来决定)表单信息,单击更新按钮,然后更新数据库再次返回主页面使主页面的信息更新.
我的代码:
<%@ page language="java" import="java.sql.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'insert.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<%
String id=request.getParameter("id");
String name=request.getParameter("name");
String xuehao=request.getParameter("xuehao");
String tel=request.getParameter("tel");
String qq=request.getParameter("qq");
Class.forName("com.mysql.jdbc.Driver");
Connection conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/my","root","123");
Statement pstmt=conn.createStatement();
conn.setAutoCommit(false);
String sql="UPDATE t_student SET name = '"+name+"' WHERE id='"+id+"'",
sql2="UPDATE t_student SET xuehao = '"+xuehao+"' WHERE id='"+id+"' ",
sql4="UPDATE t_student SET tel = '"+tel+"' WHERE id='"+id+"'" ,
sql5="UPDATE t_student SET qq = '"+qq+"' WHERE id='"+id+"' ";
pstmt.executeUpdate(sql);
pstmt.executeUpdate(sql2);
pstmt.executeUpdate(sql4);
pstmt.executeUpdate(sql5);
conn.commit();
pstmt.close();
conn.close();
%>
<jsp:forward page="list.jsp"></jsp:forward>
</body>
</html>
------解决思路----------------------
那肯定啊,楼主name=“selectname”的标签时subbmit按钮
自己看代码
<input type="submit" name="selectName" value="名字查询"></a>
楼主要传的应该是这个标签里的值吧
<input name="xinxi" type="text" value="请输入名字" onfocus="this.value='';" onblur="if(this.value==''){this.value='输入学号或姓名'}">如果是,那应该获取"xinxi"啊
String selectName=request.getParameter("xinxi");