[英]How can i make as proper Q&A in jsp from this table?
i want to generate question and answer from the oracle database and sort them in proper question and answer for the objective question?我想从 oracle 数据库中生成问答,并按照客观问题的正确问答对它们进行排序?
controller code控制器代码
public ArrayList<DOWNLOAD_SUB> getQUESTION_SUB2() throws SQLException{
ArrayList<DOWNLOAD_SUB> question_subssss = new ArrayList<>();
Connection connection = fACADE.getConnection();
PreparedStatement ps = connection.prepareStatement("SELECT A.QUESTION, B.ANSWER FROM QUESTION_OBJ A, OBJ_ANSWER B WHERE A.QUESTION_OBJ_ID = B.QUESTION_OBJ_ID");
ResultSet rs = ps.executeQuery();
while(rs.next()){
DOWNLOAD_SUB question_sub1=new DOWNLOAD_SUB();
question_sub1.setQUESTION(rs.getString(1));
question_sub1.setANSWER(rs.getString(2));
System.out.println(rs.getString(1));
question_subssss.add(question_sub1);
}
return question_subssss;
}
jsp file- this is normal table that repeated the same question, i don't know how to make as proper Q&A without using this table jsp 文件-这是重复相同问题的普通表,我不知道如何在不使用此表的情况下进行正确的问答
<table class="table" border=2 bgcolor="white">
<thead>
<tr>
<th>QUESTION</th>
<th>AWNSER</th>
</tr>
</thead>
<tbody>
<%
for (DOWNLOAD_SUB fquestion_sub : DOWNLOAD_SUB2)
{
%>
<tr>
<td><%=fquestion_sub.getQUESTION()%></td>
<td><%=fquestion_sub.getANSWER()%></td>
</tr>
<%
}
%>
the result is结果是
QUESTION |ANSWER
WHAT ARE THE MOLECULE STATE THAT OCCUR DURING HIGH PRESSURE? |IRON
WHAT ARE THE MOLECULE STATE THAT OCCUR DURING HIGH PRESSURE? |GAS STATE
WHAT ARE THE MOLECULE STATE THAT OCCUR DURING HIGH PRESSURE? |LIQUID
WHAT ARE THE MOLECULE STATE THAT OCCUR DURING HIGH PRESSURE? |SOLID
what i need is我需要的是
1)WHAT ARE THE MOLECULE STATE THAT OCCUR DURING HIGH PRESSURE?
A. IRON
B. GAS STATE
C. LIQUID
D. SOLID
Assuming DOWNLOAD_SUB2 is single question with multiple choice假设 DOWNLOAD_SUB2 是单选题
<%=DOWNLOAD_SUB2.get(0).getQUESTION()%>
<ol type="A">
<% for (DOWNLOAD_SUB fquestion_sub : DOWNLOAD_SUB2) { %>
<li><%=fquestion_sub.getANSWER()%></li>
<% } %>
</ol>
Instead of using HTML Table tags, you can use Ordered list tags <ol>
and <li>
您可以使用有序列表标签
<ol>
和<li>
,而不是使用 HTML Table 标签
Ideally your data structure should be a Map<String, List<String>>
where key in the Map is the question, and list is the multiple choices.理想情况下,您的数据结构应该是
Map<String, List<String>>
,其中 Map 中的 key 是问题,而 list 是多项选择。
Create an ordered list of ordered lists of type="A"创建类型为 =“A”的有序列表的有序列表
<!-- Open the question list -->
<ol>
// Add your For loop here...
<li>
<p>WHAT ARE THE MOLECULE STATE THAT OCCUR DURING HIGH PRESSURE?</p>
<!-- Open the answer list -->
<ol type="A">
<li>IRON</li>
<li>GAS STATE</li>
<li>LIQUID</li>
<li>SOLID</li>
</ol>
</li>
// End your loop here...
</ol>
This will output: 1. WHAT ARE THE MOLECULE STATE THAT OCCUR DURING HIGH PRESSURE?这将输出: 1. 在高压期间发生的分子状态是什么?
A. IRON
B. GAS STATE
C. LIQUID
D. SOLID
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.