Javascript <;a>;html中的标记
我在JSP文件中有以下代码:Javascript <;a>;html中的标记,javascript,html,jsp,Javascript,Html,Jsp,我在JSP文件中有以下代码: rs=stmt.executeQuery("select * from routemaster"); if(rs!=null){ %> <table class="notebook" align="center"> <tr class=row_title> <th class=row_title>RouteID</th> <th class=row_title>Route
rs=stmt.executeQuery("select * from routemaster");
if(rs!=null){
%>
<table class="notebook" align="center">
<tr class=row_title>
<th class=row_title>RouteID</th>
<th class=row_title>RouteCode</th>
<th class=row_title>BusNo</th>
<th class=row_title>InBoundTime</th>
<th class=row_title>OutBoundtime</th>
<th class=row_title>Location</th></tr>
<%
while(rs.next()){
RouteID=rs.getString(1);
RouteCode=rs.getString(2);
InBoundtime=rs.getString(4);
OutBoundtime=rs.getString(5);
BusNo=rs.getString(6);
Location=rs.getString(7);
DisRow++;
%><tr class= <%=(DisRow%2!=0)? "row_even" : "row_odd"%>>
<td><%=RouteID%></td>
<td><a onclick="sendInfo('<%=RouteCode%>') " ><%=RouteCode%></a></td>
<td><%=BusNo%></td>
<td><%=InBoundtime%></td>
<td><%=OutBoundtime%></td>
<td><%=Location%></td>
</tr><%
}
%></table><%
}
无论何时单击与
RouteCode
的链接,都需要关闭窗口,并且所选的RouteCode
需要存储在会话中。如何实现这一点?关键是,您需要将值从客户端发送到服务器。实现这一点的正常方法是让客户端单击链接或将表单提交到服务器端的URL,并将值作为URL中的请求参数或表单中的隐藏输入发送
由于您使用的是链接,下面是一个链接示例:
然后在sendInfo.jsp中
window.opener.document.addbus0.RouteCode.value='';
window.close();
与具体问题无关,此代码样式不是最佳实践。Java代码属于Java类,而不是JSP文件。JSP文件应该只包含HTML、JSP标记和EL。另请参见变量名称应以小写字母开头的规定。仔细阅读。你还有很长的路要走,祝你好运。当你说session时,你是在说服务器端的HttpSession
?浏览器中没有会话。此外,不建议从JSP中的scriptlet执行SQL。您可能至少希望使用JSTL进行循环。
sendInfo(txt){
var txt = window.opener.document.addbus0.RouteCode;
txt.value = txtVal;
window.close();
}