【发布时间】:2016-06-27 12:00:22
【问题描述】:
我的网站就像 SO。在此页面中,我试图在两个单独的表格中检索已回答和未回答的问题。但在输出中,我在已回答问题表中显示了已回答和未回答的问题。这里出了什么问题?我感谢所有的帮助和努力。这是我的代码:-
<%@page import="model.QuestionBean"%>
<%@page import="java.util.List"%>
<%@page import="model.QuestionDAO"%>
<%@page import="model.QuestionDAOFactory"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>All Questions</title>
</head>
<body>
<div>
<%
QuestionDAOFactory qdf=new QuestionDAOFactory();
QuestionDAO qd=qdf.createQuestionDAO();
List<QuestionBean> list=qd.getQuestions();
for (QuestionBean qb : list) {
%>
<%
if(qb.getIsAnswered().equalsIgnoreCase("Y"))
%>
<table style="width: 50%;height: 100%;border: 1px solid black;" align="">
<thead>
<tr>
<th>Answered Questions</th>
</tr>
</thead>
<tbody>
<%
{
%>
<tr><td><a href="viewQuestion.jsp?id=<%=qb.getQuestionId() %>"><%=qb.getQuestionText() %></a></td></tr>
<%
}
%>
</tbody>
</table>
<%
else
%>
<table style="width: 50%;height: 100%;border: 1px solid black;" align="">
<thead>
<tr>
<th>Unanswered Questions</th>
</tr>
</thead>
<tbody>
<%
{
%>
<tr><td><a href="viewQuestion.jsp?id=<%=qb.getQuestionId() %>"><%=qb.getQuestionText() %></a></td></tr>
<%
}
%>
</tbody>
</table>
<%
}
%>
</table>
</div>
</body>
</html>
【问题讨论】:
标签: java jsp if-statement