Java 如何发送到另一个jsp页面并不是第一件事,它的用途是什么
我正在制作关于管理员的页面。我想接受我的会员谁是注册。我使用2个jsp页面一个是显示和发送数据(产品代码),另一个是接收数据 问题是,如果我对一个人单击accepct按钮,这是place列而不是first,则会对place first cloumn的另一个人进行检查 这是代码 admin_members.jspJava 如何发送到另一个jsp页面并不是第一件事,它的用途是什么,java,forms,jsp,for-loop,input,Java,Forms,Jsp,For Loop,Input,我正在制作关于管理员的页面。我想接受我的会员谁是注册。我使用2个jsp页面一个是显示和发送数据(产品代码),另一个是接收数据 问题是,如果我对一个人单击accepct按钮,这是place列而不是first,则会对place first cloumn的另一个人进行检查 这是代码 admin_members.jsp <form name="form_n" class="form_n" method="POST" action="save/admin_mem_accept.jsp">
<form name="form_n" class="form_n" method="POST" action="save/admin_mem_accept.jsp">
<table class="no_members table" data-toggle="table" data-show-refresh="true">
<tr>
<th>Email</th>
<th>Name</th>
<th>Accept</th>
</tr>
<%
Vector userid_n = new Vector();
Vector user_name_n = new Vector();
Connection con= null;
Statement st =null;
ResultSet rs =null;
try {
Class.forName("org.gjt.mm.mysql.Driver");
} catch (ClassNotFoundException e ) {
out.println(e);
}
try{
con = DriverManager.getConnection("jdbc:mysql://localhost/becomeus?useUnicode=true&characterEncoding=utf8","root","qlzjadjtm!2");
} catch (SQLException e) {
out.println(e);
}
try {
st = con.createStatement();
String sql = "select * from members where isok="+false;
rs = st.executeQuery(sql);
if (!rs.next()) {
out.println("<tr><td colspan='3' align='center'>");
out.println("No Customers.");
out.println("</td></tr>");
} else {
do {
userid_n.addElement(rs.getString("userid"));
user_name_n.addElement(rs.getString("user_name"));
} while(rs.next());
int totalrows = userid_n.size();
for (int j=0; j<=(totalrows-1); j++) {
user_id = (String)userid_n.elementAt(j);
out.println("<tr>");
out.println("<td>"+userid_n.elementAt(j)+"</td>");
out.println("<td>"+user_name_n.elementAt(j)+"</td>");
out.println("<td><input type='hidden' id='input_"+j+"' name='userid' value='"+userid_n.elementAt(j)+"'></td>");
//out.println("<td><button type='button' class='btn btn-success' onClick='isok_accept("+userid_n.elementAt(j)+");'>Accept</button></td>");
out.println("<td><button type='button' class='btn btn-success' onClick='submit_n();'>Accept</button></td>");
out.println("</tr>");
}
}
} catch (java.sql.SQLException e) {
out.println(e);
}
%>
</table>
</form>
电子邮件
名称
接受
下面是显示和发送数据的代码。我使用“input”标记是因为我需要发送数据
admin\u mem\u accept.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page language="java" import="java.sql.*,java.util.*" %>
<%
String userid = request.getParameter("userid");
String query = new String();
Connection conn = null;
Statement stmt = null;
PreparedStatement pstmt = null;
try {
Class.forName("org.gjt.mm.mysql.Driver");
} catch (ClassNotFoundException e ) {
out.println(e);
}
try {
conn = DriverManager.getConnection("jdbc:mysql://localhost/becomeus?useUnicode=true&characterEncoding=utf8","root","qlzjadjtm!2");
stmt = conn.createStatement();
query = "update members set isok="+true+" where userid=?";
pstmt = conn.prepareStatement(query);
pstmt.setString(1, userid);
pstmt.executeUpdate();
} catch(SQLException e){
out.println(e);
} finally {
conn.close();
}
response.sendRedirect("../admin_members.jsp");
%>
下面是另一个接收数据的代码
使用“输入”有问题吗?我怎样才能发送给一个人而不是第一个?
谢谢。问题是您在单击按钮时没有提到任何特定的id。所以我希望它将第一个值作为默认值。我的建议是将行的特定id传递给javascript函数,并发送ajax请求以删除特定记录。成功删除后,请刷新页面.Hi。我用另一种方式解决了这个问题。谢谢你的评论!问题是您在单击按钮时没有提到任何特定的id。所以我希望它将第一个值作为默认值。我的建议是将行的特定id传递给javascript函数,并发送ajax请求以删除特定记录。成功删除后,请刷新页面.Hi。我用另一种方式解决了这个问题。谢谢你的评论!