list.jsp转到detail.jsp, 通过一个<a href="detail.jsp"><font color="blue">Detail</font></a> 50
程序是这样的:list.jsp里显示的是信息某个内容的列表,想要做的是,点击“detail”这个单词,就会跳转到该信息的全部具体内容。问题1:需不需要建立一个servle...
程序是这样的:
list.jsp里显示的是信息某个内容的列表,想要做的是,点击“detail”这个单词,就会跳转到该信息的全部具体内容。
问题1:需不需要建立一个servlet.java?
如果不需要,能否显示出我点击的某个信息,而非所有~~因为在list.jsp里,每个列表都有id
问题2:如果需要建立一个servlet.java,如何将我点击的list的id传递给servlet,再传给detail.jsp。
list.jsp代码是这样的:
<%String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
Rentalproperty[] resultrp=(Rentalproperty[])session.getAttribute("sessionresultrp");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">
<title>Search Result For Property</title>
</head>
<body>
<%@ include file="Header.html"%>
<center>
<h1>Search Result For Property</h1>
<a href="welcome.jsp"><font color="blue">HomePage</font></a><a href="mycart"></a>
<a href="itinerary.jsp"><font color="blue">Generate Itinerary</font></a>
<a href="javascript:history.go(-1)"><font color="blue">LastPage</font></a>
<hr>
<form id="form3" name="form3" method="POST" action="cartservlet">
<%
int count=0;
SimpleDateFormat formatxml = new SimpleDateFormat("yyyyMMddHHmm");
Date date=new Date();
String current=formatxml.format(date);
boolean passInspection = true;
String[] idArray = new String[25];
if(resultrp!=null && resultrp.length!=0) {
while(count<resultrp.length) {
if(resultrp[count].Inspection.compareTo(current) > 0) {
passInspection = false;
%>
<h2>Address: <%= resultrp[count].Address%></h2>
<h3><input type="checkbox" name="cart" id="cart" value="<%=count%>"/>Add
<a href="infoservlet?id=<%= resultrp[count].Id%>"><font color="blue">Detail</font></a></h3>
(---------------------------------------------重点看上面一行)
<img src="<%= resultrp[count].Picture %>">
<hr>
<br>
<% /*idArray[count] = resultrp[count].Id;*/
}
count++;
}
if(count == resultrp.length && passInspection)
{%>
<h2><font color="red">Sorry! Inspection date and time has passed!</font></h2>
<%}
}
else {%>
<h2><font color="red">Sorry! We don't have that kind of property!</font></h2>
<%}
if(resultrp!=null && resultrp.length!=0) {%>
<br><input type="submit" value="Add to Itinerary"/>
<%}%>
</form>
</form>
</center>
<hr>
<%@ include file="footer.jsp"%>
</body>
</html>
如何将id传到servlet中去,请给出servlet的具体代码~~
和detail.jsp中如何将servlet中id传入的具体语句~~
多谢~~ 展开
list.jsp里显示的是信息某个内容的列表,想要做的是,点击“detail”这个单词,就会跳转到该信息的全部具体内容。
问题1:需不需要建立一个servlet.java?
如果不需要,能否显示出我点击的某个信息,而非所有~~因为在list.jsp里,每个列表都有id
问题2:如果需要建立一个servlet.java,如何将我点击的list的id传递给servlet,再传给detail.jsp。
list.jsp代码是这样的:
<%String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
Rentalproperty[] resultrp=(Rentalproperty[])session.getAttribute("sessionresultrp");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">
<title>Search Result For Property</title>
</head>
<body>
<%@ include file="Header.html"%>
<center>
<h1>Search Result For Property</h1>
<a href="welcome.jsp"><font color="blue">HomePage</font></a><a href="mycart"></a>
<a href="itinerary.jsp"><font color="blue">Generate Itinerary</font></a>
<a href="javascript:history.go(-1)"><font color="blue">LastPage</font></a>
<hr>
<form id="form3" name="form3" method="POST" action="cartservlet">
<%
int count=0;
SimpleDateFormat formatxml = new SimpleDateFormat("yyyyMMddHHmm");
Date date=new Date();
String current=formatxml.format(date);
boolean passInspection = true;
String[] idArray = new String[25];
if(resultrp!=null && resultrp.length!=0) {
while(count<resultrp.length) {
if(resultrp[count].Inspection.compareTo(current) > 0) {
passInspection = false;
%>
<h2>Address: <%= resultrp[count].Address%></h2>
<h3><input type="checkbox" name="cart" id="cart" value="<%=count%>"/>Add
<a href="infoservlet?id=<%= resultrp[count].Id%>"><font color="blue">Detail</font></a></h3>
(---------------------------------------------重点看上面一行)
<img src="<%= resultrp[count].Picture %>">
<hr>
<br>
<% /*idArray[count] = resultrp[count].Id;*/
}
count++;
}
if(count == resultrp.length && passInspection)
{%>
<h2><font color="red">Sorry! Inspection date and time has passed!</font></h2>
<%}
}
else {%>
<h2><font color="red">Sorry! We don't have that kind of property!</font></h2>
<%}
if(resultrp!=null && resultrp.length!=0) {%>
<br><input type="submit" value="Add to Itinerary"/>
<%}%>
</form>
</form>
</center>
<hr>
<%@ include file="footer.jsp"%>
</body>
</html>
如何将id传到servlet中去,请给出servlet的具体代码~~
和detail.jsp中如何将servlet中id传入的具体语句~~
多谢~~ 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询