问题描述
- 搜索引擎 web 界面 不能执行功能
-
主页index.jsp文件。<%@page language="java" contentType="text/html;charset=gb2312" pageEncoding="gb2312"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <link rel="stylesheet" type="text/css" href="style.css" /> <title>搜索引擎</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <script type='text/javascript' src='${pageContext.request.contextPath}dwr/engine.js'></script> <script type='text/javascript' src='${pageContext.request.contextPath}dwr/util.js'></script> <script type='text/javascript' src='${pageContext.request.contextPath}dwr/interface/SearchService.js'></script> <script language="javascript"> var request; var minpage; var maxpage; var startindex; var hasnext; function doSearch(type){ var result = document.getElementById("result"); var pagingdiv = document.getElementById('paging'); result.innerHTML=""; pagingdiv.innerHTML = ""; if (type != 'paging') { var startindexinput = document.getElementById('startindex'); startindexinput.value = "1"; } request = {startindex:1, query:""}; document.getElementById(request); SearchService.getSearchResults(request, fillPage); } function fillPage(data){ var list = data.results; var resultdiv = document.getElementById('result').value; var pagingdiv = document.getElementById('paging').value; resultdiv.innerHTML = ""; pagingdiv.innerHTML = ""; if (list.length == 0) { resultdiv.innerHTML = "<span>Sorry, we can't find what you want...</span>"; return; } for(var i=0; i<list.length; i++) { var ele = document.createElement('div'); ele.setAttribute('id','info' + list[i]); ele.innerHTML = "<span>loading..</span>"; resultdiv.appendChild(ele); searchService.getSearchResultById(list[i], fillDetailResult); } minpage = data.minpage; maxpage = data.maxpage; startindex = data.startindex; hasnext = data.hasnext; if (minpage != 1) { var link = document.createElement('a'); link.setAttribute("href","javascript:page('" + ((minpage-11)*10+1) + "')"); link.innerHTML = "前10页<<"; pagediv.appendChild(link); } for (var j=minpage; j <=maxpage; j++) { if ((j-1)*10+1 != startindex) { var link = document.createElement('a'); link.setAttribute("href","javascript:page('" + ((j-1)*10+1) + "')"); link.innerHTML = "第" + j + "页"; pagingdiv.appendChild(link); } else { pagingdiv.innerHTML += ("第" + j + "页"); } } if (hasnext == 1) { var link = document.createElement('a'); link.setAttribute("href","javascript:page('" + (maxpage*10+1) + "')"); link.innerHTML = ">>后10页"; pagingdiv.appendChild(link); } } function fillDetailResult(record) { var result = document.getElementById('info' + record.id); result.innerHTML="<table border='0' cellpadding='0' cellspacing='0' width=500><tr><td width='120'><img src='../showpic?id=" + record.imageUrl + "' /></td><td><a href='detail.jsp?id=" + record.id + "' target='_blank'><font color=#C60A00 size='2'>" + "<font size='2'>景点:</font>" + record.name + "</font><br>" + "<font size='2'>地址:" + record.type + "</font><br><font color=#C60A00 size='2'>" + record.abstractContent + "......" + "</font><br><a href='" + record.url + "'>" + "<font size=2>" + record.url + "</font>" + "</td></tr></table>"; } function paging(newindex) { document.getElementById('startindex').value = newindex; doSearch('paging'); } function handlekey(){ if (document.getElementById('query').value == '') return; var intkey = -1; if(window.event) { intKey = event.keyCode; if(intKey == 13){ doSearch(''); } } } </script> </head> <body> <input type="hidden" name="startindex" id="startindex" value="1"> <!-- 这是搜索栏 --> <body> <input type="hidden" name="startindex" id="startindex" value="1"> <!-- 这是搜索栏 --> <div id="searchbar"> <table align="center"> <tr align="center"> <td> <img src="logo.jpg" /> </td> </tr> <tr align="center"> <td><input size="50" type="text" name="query" id="query" value="诺基亚" onkeyup="handlekey()"> <input type="button" value="Search" id="search" onclick="javascript:doSearch('')"></td> </tr> </table> </div> <hr> <!-- 这是结果栏 --> <div id="result"> </div> <hr> <!-- 这是分页栏 --> <div id="paging"> </div> <!-- 这是Footer--> <div id="footer"> <table align="center"> <tr align="center"> <td> <img src="footer.jpg" /> </td> </tr> </table> </div> </body> </html>
dwr配置。
<?xml version="1.0" encoding="gb2312"?> <!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 3.0//EN" "http://getahead.org/dwr/dwr30.dtd"> <dwr> <allow> <create creator="spring" javascript="SearchService"> <param name="beanName" value="searchService" /> </create> <!-- Bean for Search --> <convert converter="bean" match="com.luceneheritrixbook.searchengine.bo.SearchResult"> </convert> <convert converter="bean" match="com.luceneheritrixbook.searchengine.bo.SearchResults"> </convert> <convert converter="bean" match="com.luceneheritrixbook.searchengine.bo.SearchRequest"> </convert> </allow> </dwr> web配置。 <?xml version="1.0" encoding="gb2312"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <display-name>Spec Builder</display-name> <context-param> <param-name>contextConfigLocation</param-name> <param-value>WEB-INF/classes/applicationContext.xml</param-value> </context-param> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener> <filter> <filter-name>response-filter</filter-name> <filter-class>com.luceneheritrixbook.searchengine.filter.SetResponseFilter</filter-class> </filter> <filter-mapping> <filter-name>response-filter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <servlet> <servlet-name>dwr-invoker</servlet-name> <servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class> <init-param> <param-name>debug</param-name> <param-value>true</param-value> </init-param> </servlet> <servlet> <servlet-name>showPic</servlet-name> <servlet-class>com.luceneheritrixbook.searchengine.servlet.ShowPicServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>dwr-invoker</servlet-name> <url-pattern>/dwr/*</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>showPic</servlet-name> <url-pattern>/showpic</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>specialst.jsp</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list> </web-app>
在tomcat运行 只能打开界面 不能执行搜索功能,哪位大神能给解决??解决后必有重赏!!
解决方案
不能搜索,你的搜索数据来源是哪?怎么执行搜索的。
最好发一下源码包,这样方便调试。
时间: 2025-01-29 18:53:27