日期:2014-05-16 浏览次数:20695 次
信息: Exec: searchService2.getSearchResults() Unknown column 'admin' in 'where clause' java.lang.NullPointerException at com.searcher.service.impl.SearchService2Impl.getSearchResults(SearchService2Impl.java:47)
public List<SearchResults2> getSearchResults(HttpServletRequest request) { JDBConnection conn = new JDBConnection(); List<SearchResults2> list = new ArrayList<SearchResults2>(); try { IndexSearcher searcher = new IndexSearcher(INDEX_STORE_PATH); Hits hits = null; String item[] = null; //HttpSession session = request.getSession(); //String name = (String) session.getAttribute("name"); String name = request.getParameter("name"); System.out.println(name); String sql = "select * from user where name like '" +name+"'"; ResultSet rs = conn.executeQuery(sql); System.out.println("......"); while (rs.next()) { String words = rs.getString(3); item = words.split("!"); System.out.println(item); } for (int i = 0; i < item.length; i++) { Query query = makeQuery(item[i]); hits = searcher.search(query); int length = hits.length(); for (int j = 1; j <= length && j <= 20; j++) { SearchResults2 results = new SearchResults2(); Document doc = hits.doc(j - 1); String pageid = doc.get("pageid"); String pagetitle = doc.get("title"); String pageurl = doc.get("url"); String pagecontent = choose(doc.get("content"), item[i]); results.setId(pageid); results.setTitle(pagetitle); results.setUrl(pageurl); results.setContent(pagecontent); list.add(results); } } } catch (Exception e) { e.printStackTrace(); } return list; }
<create creator="new" javascript="searchService2"> <param name="class" value="com.searcher.service.impl.SearchService2Impl" /> </create> <convert converter="bean" match="com.searcher.bo.SearchResults2"> </convert>