JSP<form action="SearchSQuestion" method="post">
<table align="center">
<tr>
<td><label>题目内容:</label></td>
<td><input name="problem" type="text" value="${problem}"/></td>
<td> </td>
<td><label>答案:</label></td>
<td><input name="answer" type="text" value="${answer}"/></td>
<td> </td>
<td><button class="btn btn-primary" style="margin-bottom: 8px;" type="submit" >查询</button></td>
</tr>
</table>
</form>DAO// 条件查询单选题信息
public List<Schoice> SearchSchoice(String problem, String answer) {
ArrayList<Schoice> list = new ArrayList<Schoice>();
try {
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://127.0.0.1:3306/appoi";
Connection con = DriverManager.getConnection(url, "root", "123348");
StringBuilder sql = new StringBuilder(
"select id,problem,optionA,optionB,optionC,optionD,answer,jointime from s_choice where 1=1 ");
List<String> paramList = new ArrayList<String>();Servletprotected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
String problem = request.getParameter("problem");
String answer = request.getParameter("answer");
request.setAttribute("problem",problem);
request.setAttribute("answer",answer);
a list =new a();
request.setAttribute("sc",list.querySchoiceList(problem, answer));
request.getRequestDispatcher("/searchsquestion.jsp").forward(request,response);
}servicepublic List<Schoice> querySchoiceList(String problem, String answer) {
SQuestionDao sq = new SQuestionDao();
return sq.SearchSchoice(problem, answer);
}
添加回答
举报
0/150
提交
取消