第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

幫忙看一下為什么輸入查詢條件后查詢不到信息

幫忙看一下為什么輸入查詢條件后查詢不到信息

慕森王 2019-04-24 16:15:13
JSP<form action="SearchSQuestion" method="post">             <table align="center">                 <tr>                     <td><label>題目?jī)?nèi)容:</label></td>                     <td><input name="problem" type="text" value="${problem}"/></td>                     <td>&nbsp;</td>                     <td><label>答案:</label></td>                     <td><input name="answer" type="text" value="${answer}"/></td>                     <td>&nbsp;</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); }
查看完整描述

2 回答

?
白豬掌柜的

TA貢獻(xiàn)1893條經(jīng)驗(yàn) 獲得超10個(gè)贊

貼這么一大堆沒(méi)用,且不說(shuō)這里任意一個(gè)地方都可能出錯(cuò),而且數(shù)據(jù)庫(kù)表、配置和用戶的輸入也會(huì)可能導(dǎo)致查詢不出來(lái)。
你得學(xué)會(huì)調(diào)試。
調(diào)試的關(guān)鍵點(diǎn)在于,首先檢查dao的代碼得到的參數(shù)problem answer是否正確傳進(jìn)來(lái)了
try catch丟出什么錯(cuò)誤了,返回值是什么
縮小你的錯(cuò)誤可能發(fā)生位置的范圍,直到找到問(wèn)題。

查看完整回答
反對(duì) 回復(fù) 2019-05-14
?
江戶川亂折騰

TA貢獻(xiàn)1851條經(jīng)驗(yàn) 獲得超5個(gè)贊

如果dao傳不進(jìn)去,你dao的代碼可以不用看了,然后看String problem = request.getParameter("problem");等,這里又沒(méi)有傳進(jìn)去

查看完整回答
反對(duì) 回復(fù) 2019-05-14
  • 2 回答
  • 0 關(guān)注
  • 873 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)