Java 如何从jsp向servlet传递表行数据?

Java 如何从jsp向servlet传递表行数据?,java,jsp,servlets,Java,Jsp,Servlets,我的jasp中有一个html表,它显示了id和month的对,如下所示: <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@page import="java.util.Map"%> <%@page import="java.util.List"%> <%@page contentType="text/html" pageEncoding="UTF-8"%> <

我的jasp中有一个html表,它显示了id和month的对,如下所示:

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page import="java.util.Map"%>
<%@page import="java.util.List"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <form method="Post" action="payCheckInfo">
            <table id="ptable" border="1">

                <tr>
                    <td style="text-align: center;">ID</td>
                    <td style="text-align: center;">Month</td>
                </tr>



                <c:forEach var="entry" items="${EmployeeHashMap}" >
                    <!-- entry.key is employee.key -->
                    <!-- entry.value is employee.skills -->
                    <c:forEach var="month" items="${entry.value}" >
                        <tr>
                            <td><a href="payCheckInfo">${entry.key}</a></td>
                            <td>${month}</td>
                        </tr>
                    </c:forEach>
                </c:forEach>

            </table>
        </form>
    </body>
</html>Type a message

jsp如下所示:

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page import="java.util.Map"%>
<%@page import="java.util.List"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <form method="Post" action="payCheckInfo">
            <table id="ptable" border="1">

                <tr>
                    <td style="text-align: center;">ID</td>
                    <td style="text-align: center;">Month</td>
                </tr>



                <c:forEach var="entry" items="${EmployeeHashMap}" >
                    <!-- entry.key is employee.key -->
                    <!-- entry.value is employee.skills -->
                    <c:forEach var="month" items="${entry.value}" >
                        <tr>
                            <td><a href="payCheckInfo">${entry.key}</a></td>
                            <td>${month}</td>
                        </tr>
                    </c:forEach>
                </c:forEach>

            </table>
        </form>
    </body>
</html>Type a message

JSP页面
身份证件
月
${month}
键入消息

现在我希望,每当用户点击某个id(这是一个链接)时,我都会转到payCheckInfo,它是我的servlet,从那里我可以获得特定的行数据,因为在payCheckInfo中,我有一个方法,可以执行我需要对数据执行的操作,获取行的特定行数据

$(“tr.table”)。单击(函数(){
var tableData=$(this.children(“td”).map(function()){
返回$(this.text();
}).get();
警报($.trim(tableData[0])+,“+$.trim(tableData[1]));
//在这里,对Servlet payCheckInfo进行Ajax调用
});

ID1
月1
ID2
月2

您想要整行数据还是只想要id?@Satya整行数据为此使用
Jquery
@乔