新需求:题目的选项随机,题目的选项数不确定。之前的试卷题目(多选,单选)的选项没有进行随机,现在需要随机排列。exam题目,option为选项
<c:forEach item="${exams}" var="exam"> ${exam}
<c:forEach item="${exam.options}" var="option"> ${option}
</c:forEach>
</c:forEach>这个怎么做才好呢?
1 回答

MMMHUHU
TA贡献1834条经验 获得超8个赞
<%for (Object exam:exams) { out.print(exam); Collections.shuffle(exam.options); for (Object option:exam.options) { out.print(option); } } %>
使用Collections.shuffle(exam.options)
打乱列表顺序,像上面一样写小脚本,或者增加自定义标签或者增加el function
这都是没问题。
添加回答
举报
0/150
提交
取消