1. 要求
要实现的东西是类似于百度的查询:输入关键词,调用Solr接口,将查询结果按照百度的样式展现出来。页面可以参考百度。JSP命名为index.jsp,放置到根目录下,且index.jsp为默认页。这样设置可以实现比如:http://localhost:8080/?q=%E8%8B%8F%E5%B7%9E格式的调用。
2. 引用包
3. 结果页面样式
4. 实现JSP代码(将百度页面抓取下来改的)
<%@ page language="java" import="java.util.*, java.net.*, java.text.*, org.apache.solr.client.solrj.*, org.apache.solr.client.solrj.impl.*, org.apache.solr.client.solrj.response.*, org.apache.solr.common.*" pageEncoding="UTF-8"%> <%! // 代码片段一:分页相关配置参数,及方法。临时性的存放于此。生产环境中会放在别的配置类中。 // 每页显示多少条记录 private final int PAGE_ROWS = 10; // 默认分页 private final int DEFAULT_PAGES = 6; // 最大分页 private final int MAX_PAGES = 50; // 计算起始页,及实际分页值 private int[] caluPages(int curPage, long totalPages) { int[] result = new int[]{curPage, DEFAULT_PAGES}; // 默认返回当前页 if(totalPages < DEFAULT_PAGES) { // 如果总页数小于“默认分页”,则从1开始,结果就是所有页全部显示 result = new int[]{1, DEFAULT_PAGES}; }else if(curPage < DEFAULT_PAGES) { // 当前页还没有超出“默认分页”,则从1开始;但是需要修改pages值 result = new int[]{1, DEFAULT_PAGES + 3}; }else { // 此种是curPage >= DEFAULT_PAGES的情况,起始页从当前页值-每页页数的下一页算起 result = new int[]{curPage - DEFAULT_PAGES + 1, DEFAULT_PAGES+3}; } return result; } // 代码片段二:取得Solr服务器实例的代码,临时性的存放于此。生产环境中会放在别的配置类中。 private static HttpSolrServer serverNews; static { serverNews = new HttpSolrServer("http://127.0.0.1:8080/solr/news"); serverNews.setMaxRetries(1); // defaults to 0. > 1 not recommended. serverNews.setConnectionTimeout(60*1000); // 1分钟 serverNews.setSoTimeout(60*1000); // socket read timeout serverNews.setDefaultMaxConnectionsPerHost(100); serverNews.setMaxTotalConnections(100); serverNews.setFollowRedirects(false); // defaults to false serverNews.setAllowCompression(true); } %> <% // 查询参数 String q = request.getParameter("q"); // 第多少页 String pg = request.getParameter("pg"); if(q == null) q = "新闻"; if(pg == null) pg = ""; int curPage = 1; // 当前页,此是给页面用的 int startRow = 0; // 从多少条记录开始显示,此是给Solr查询用的;起始值不是从1开始,而是从0开始 if(pg != "") { curPage = Integer.parseInt(pg); startRow = (curPage-1)*PAGE_ROWS; } // 分页的链接页 String url = "index.jsp?q=" + java.net.URLEncoder.encode(q, "UTF-8"); System.out.println("查询参数:" + q + "\t查询第" + pg + "页"); %> <HTML> <HEAD> <META http-equiv=Content-Type content="text/html;charset=utf-8"> <TITLE>精度信息搜索</TITLE> <LINK rel="stylesheet" href="css/style1.css" type="text/css"/> </HEAD> <BODY link=#0000cc> <DIV id=out> <DIV id=in> <DIV id=wrapper> <DIV id=container class=container_s> <DIV id="m"> <DIV id="fm"> <FORM name="f" action="index.jsp"> <SPAN class="s_ipt_wr"> <INPUT name="q" id="q" value="<%=q%>" maxlength="100" class="s_ipt" type="text"> </SPAN> <SPAN class="s_btn_wr"> <INPUT value="精度一下" id="su" class="s_btn" type="submit"> </SPAN> </FORM> </DIV> </DIV> <% // 查询开始 SolrQuery params = new SolrQuery("text:(" + q + ")"); params.set("start", startRow); params.set("rows", PAGE_ROWS); params.set("fl", "*,score"); params.setHighlight(true); // 开启高亮组件 params.addHighlightField("webTitle");// 高亮字段 params.addHighlightField("webContent");// 高亮字段 try { QueryResponse solrResponse = serverNews.query(params); // 处理查询结果开始... SolrDocumentList sdList = solrResponse.getResults(); Map<String, Map<String, List<String>>> map = solrResponse.getHighlighting(); long numfound = sdList.getNumFound(); // 查询返回多少条记录 long elapsedtime = solrResponse.getElapsedTime(); //耗时 // 下面是输出内容的代码 SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); out.println("<DIV id=content_left>"); for (int i = 0; i < sdList.size(); i++) { SolrDocument sdocument = sdList.get(i); // 下面这些参数是存储在Lucene索引中的值,在sdList中 String objectId = (String)sdocument.get("objectId"); String webHtml = (String)sdocument.get("webHtml"); String webUrl = (String)sdocument.get("webUrl"); String webTime = ""; try { webTime = sdf.format(sdocument.get("webTime")); }catch (Exception e){ } String webCommit = (String)sdocument.get("webCommit"); String webUrlShort = webUrl; // 下面这两个字段有可能都包含关键字,也有可能只有一个包含 String title = (String)sdocument.get("webTitle"); String content = (String)sdocument.get("webContent"); if(content.length() > 100) { content = content.substring(0,100) + "..."; } Map<String, List<String>> valueMap = map.get(objectId); for (Map.Entry<String, List<String>> entry : valueMap.entrySet()) { String subkeyname = entry.getKey().toString(); String subkeyvalue = entry.getValue().get(0); if("webTitle".equals(subkeyname)) { title = subkeyvalue; }else if("webContent".equals(subkeyname)) { // 高亮是摘要信息。默认值是100 content = subkeyvalue; } } out.println("<TABLE id=1 class=result cellSpacing=0 cellPadding=0>"); out.println("<TBODY>"); out.println("<TR>"); out.println("<TD class=f>"); out.println("<H3 class=t><A href=\"" + webUrl + "\" target=_blank data-click=\"{'F':'778317EA','F1':'9D33F1E4','F2':'CCA6DE6B','F3':'54E5243F','T':'1358404362','y':'8BBC7F73'}\">"); out.println(title); out.println("</A></H3>"); out.println("<FONT size=-1>"); out.println(content); out.println("</FONT><BR><FONT size=-1></FONT><FONT size=-1>"); out.println("<SPAN class=g>" + webUrlShort + " " + webTime + "-" + webCommit + "</SPAN>"); out.println("<A class=m href=\"" + webHtml + "\" target=_blank data-nolog>精度快照</A><SPAN id=like_2663726754990454856 class=liketip data-nolog></SPAN>"); out.println("</FONT></TD></TR></TBODY></TABLE><BR>"); } out.println("</DIV>"); // 下面是输出分页的代码 // 总页数,起始页,实际分页值 long totalPages = (long)(Math.ceil((double)numfound/(double)PAGE_ROWS)); int[] pageParams = caluPages(curPage, totalPages); int startPage = pageParams[0]; int pages = pageParams[1]; System.out.println("总页数:"+ totalPages + ",当前页:" + curPage + ",起始页:" + startPage + ",实际分页:" + pages + ",Solr开始记录:" + startRow); out.println("<P id=page>"); // 如果当前页大于1,则显示上一页 if(curPage > 1) { out.println("<A class=n href=\"" + url + "&pg=" + (curPage-1) + "\"><上一页</A>"); } if(totalPages >= 1) { for(int i=startPage; i<startPage+pages; i++) { if(i > totalPages) { break; } if(curPage == i) { out.println("<STRONG><SPAN class=\"fk fk_cur\"></SPAN><SPAN class=pc>" + i + "</SPAN></STRONG>"); }else { out.println("<A href=\"" + url + "&pg=" + i + "\"><SPAN class=\"fk fkd\"></SPAN><SPAN class=pc>" + i + "</SPAN></A>"); } } } // 如果当前页小于总页数,则显示下一页(如果无结果,则当前页为1,总页数为0) if(curPage < totalPages) { out.println("<A class=n href=\"" + url + "&pg=" + (curPage+1) + "\">下一页></A>"); } out.println("<SPAN style=\"MARGIN-LEFT: 20px\" class=nums>精度为您找到相关结果约" + numfound + "个,耗时:" + elapsedtime + "毫秒</SPAN>"); out.println("</P>"); out.println("<BR/>"); } catch (SolrServerException e) { e.printStackTrace(); } %> </DIV> </DIV> </DIV> </DIV> </BODY> </HTML>
5. 样式文件参考(从百度页面里摘取出来的)
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
BODY { POSITION: relative; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; BACKGROUND: #fff; COLOR: #000; PADDING-TOP: 6px } BODY { FONT-FAMILY: arial } TH { FONT-FAMILY: arial } TD { FONT-FAMILY: arial } .p1 { FONT-FAMILY: arial } .p2 { FONT-FAMILY: arial } P { PADDING-BOTTOM: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px } FORM { PADDING-BOTTOM: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px } OL { PADDING-BOTTOM: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px } UL { PADDING-BOTTOM: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px } LI { PADDING-BOTTOM: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px } DL { PADDING-BOTTOM: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px } DT { PADDING-BOTTOM: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px } DD { PADDING-BOTTOM: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px } H3 { PADDING-BOTTOM: 0px; LIST-STYLE-TYPE: none; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px } INPUT { BOX-SIZING: border-box; PADDING-BOTTOM: 0px; PADDING-TOP: 0px; -moz-box-sizing: border-box; -webkit-box-sizing: border-box } TABLE { BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px } IMG { BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px } TD { LINE-HEIGHT: 18px; FONT-SIZE: 9pt } EM { FONT-STYLE: normal; COLOR: #cc0000 } A EM { TEXT-DECORATION: underline } CITE { FONT-STYLE: normal; COLOR: #008000 } .m { COLOR: #666 } A.m { COLOR: #666 } A.m:visited { COLOR: #606 } .g { COLOR: #008000 } A.g { COLOR: #008000 } .c { COLOR: #77c } .f14 { FONT-SIZE: 14px } .f10 { FONT-SIZE: 10.5pt } .f16 { FONT-SIZE: 16px } #u { FONT-SIZE: 12px } #head { FONT-SIZE: 12px } #tool { FONT-SIZE: 12px } #search { FONT-SIZE: 12px } #foot { FONT-SIZE: 12px } .p1 { LINE-HEIGHT: 120%; MARGIN-LEFT: -12pt } .p2 { LINE-HEIGHT: 120%; WIDTH: 100%; MARGIN-LEFT: -12pt } #out { _margin-left: 880px; _zoom: 1 } #in { _margin-left: -880px; _position: relative; _float: left } #wrapper { MIN-WIDTH: 880px; _zoom: 1 } #container { PADDING-LEFT: 20px } .container_s { WIDTH: 967px } .container_l { WIDTH: 1187px } #content_left { WIDTH: 636px } #content_right { FLOAT: right } .container_s #content_right { WIDTH: 281px } .container_l #content_right { WIDTH: 451px } #u { Z-INDEX: 299; POSITION: absolute; WHITE-SPACE: nowrap; COLOR: #999; TOP: 4px; RIGHT: 10px; _top: 0 } #u A { MARGIN: 0px 5px; COLOR: #00c } #u .reg { MARGIN: 0px } #u .last { MARGIN-RIGHT: 0px } #u .un { PADDING-RIGHT: 11px; BACKGROUND: url(http://www.baidu.com/cache/global/img/bg-1.1.0.png) no-repeat right -195px; FONT-WEIGHT: bold; MARGIN-RIGHT: 5px } #u UL { BORDER-BOTTOM: #9b9b9b 1px solid; BORDER-LEFT: #9b9b9b 1px solid; WIDTH: 100%; BACKGROUND: #fff; BORDER-TOP: #9b9b9b 1px solid; BORDER-RIGHT: #9b9b9b 1px solid } #u LI { HEIGHT: 25px } #u LI A { TEXT-ALIGN: left; FILTER: none; LINE-HEIGHT: 25px; TEXT-INDENT: 6px; MARGIN: 0px; WIDTH: 100%; DISPLAY: block; HEIGHT: 25px; TEXT-DECORATION: none } #u LI A:hover { BACKGROUND: #ebebeb } #u LI.nl { BORDER-TOP: #ebebeb 1px solid } #userMenu { POSITION: absolute; WIDTH: 64px; DISPLAY: none; BACKGROUND: #fff; TOP: 15px; RIGHT: 7px; PADDING-TOP: 4px; _right: 2px } #user { POSITION: relative; DISPLAY: inline-block } #head { PADDING-LEFT: 20px } .fm { Z-INDEX: 297; POSITION: relative; CLEAR: both } .nv A { FONT-SIZE: 14px } .nv B { FONT-SIZE: 14px } .btn { FONT-SIZE: 14px } #page { FONT-SIZE: 14px } #more { FONT-SIZE: 14px } .s_nav { HEIGHT: 45px } .s_nav .s_logo { FLOAT: left; MARGIN-RIGHT: 20px } .s_nav .s_logo IMG { BORDER-RIGHT-WIDTH: 0px; DISPLAY: block; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px } .s_nav .s_tab { PADDING-BOTTOM: 0px; LINE-HEIGHT: 18px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; FLOAT: left; PADDING-TOP: 20px } .s_nav A { COLOR: #0000cc; FONT-SIZE: 14px } .s_nav B { FONT-SIZE: 14px } .s_ipt_wr { BORDER-BOTTOM: #b6b6b6 1px solid; BORDER-LEFT: #7b7b7b 1px solid; WIDTH: 533px; DISPLAY: inline-block; BACKGROUND: url(http://s1.bdstatic.com/r/www/img/i-1.0.0.png) no-repeat -304px 0px; HEIGHT: 30px; VERTICAL-ALIGN: top; BORDER-TOP: #7b7b7b 1px solid; MARGIN-RIGHT: 5px; BORDER-RIGHT: #b6b6b6 1px solid } .s_ipt { PADDING-BOTTOM: 0px; BORDER-RIGHT-WIDTH: 0px; MARGIN: 5px 0px 0px 7px; PADDING-LEFT: 0px; OUTLINE-WIDTH: 0px; WIDTH: 520px; PADDING-RIGHT: 0px; FONT: 16px/22px arial; BACKGROUND: #fff; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; HEIGHT: 22px; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px; -webkit-appearance: none } .s_btn { PADDING-BOTTOM: 0px; BORDER-RIGHT-WIDTH: 0px; PADDING-LEFT: 0px; WIDTH: 95px; PADDING-RIGHT: 0px; BACKGROUND: url(http://s1.bdstatic.com/r/www/img/i-1.0.0.png) #ddd; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; HEIGHT: 32px; FONT-SIZE: 14px; BORDER-LEFT-WIDTH: 0px; CURSOR: pointer; PADDING-TOP: 0px } .s_btn_h { BACKGROUND-POSITION: -100px 0px } .s_btn_wr { Z-INDEX: 0; POSITION: relative; WIDTH: 97px; DISPLAY: inline-block; BACKGROUND: url(http://s1.bdstatic.com/r/www/img/i-1.0.0.png) no-repeat -202px 0px; HEIGHT: 34px; VERTICAL-ALIGN: top } .sethf { PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; FONT-SIZE: 14px; PADDING-TOP: 0px } .set_h { DISPLAY: none; BEHAVIOR: url(#default#homepage) } .set_f { DISPLAY: none } .shouji { MARGIN-LEFT: 22px } #tb_mr { Z-INDEX: 298; POSITION: relative; COLOR: #00c; CURSOR: pointer } #tb_mr B { FONT-WEIGHT: normal; TEXT-DECORATION: underline } #tb_mr SMALL { FONT-SIZE: 11px } #page { FONT: 14px simsun; WHITE-SPACE: nowrap } #page A { TEXT-ALIGN: center; LINE-HEIGHT: 22px; DISPLAY: inline-block; BACKGROUND: white; HEIGHT: 54px; VERTICAL-ALIGN: text-bottom; OVERFLOW: hidden; MARGIN-RIGHT: 5px; TEXT-DECORATION: none } #page STRONG { TEXT-ALIGN: center; LINE-HEIGHT: 22px; DISPLAY: inline-block; BACKGROUND: white; HEIGHT: 54px; VERTICAL-ALIGN: text-bottom; OVERFLOW: hidden; MARGIN-RIGHT: 5px; TEXT-DECORATION: none } #page A { CURSOR: pointer } #page A:hover { BACKGROUND: 0px 50% } #page .n:hover { BACKGROUND: #ebebeb } #page A:hover .pc { BACKGROUND: #ebebeb } #page .n { BORDER-BOTTOM: #e7ecf0 1px solid; BORDER-LEFT: #e7ecf0 1px solid; PADDING-BOTTOM: 0px; PADDING-LEFT: 6px; PADDING-RIGHT: 6px; HEIGHT: 22px; BORDER-TOP: #e7ecf0 1px solid; BORDER-RIGHT: #e7ecf0 1px solid; PADDING-TOP: 0px } #page SPAN { DISPLAY: block } #page .pc { BORDER-BOTTOM: #e7ecf0 1px solid; BORDER-LEFT: #e7ecf0 1px solid; WIDTH: 22px; HEIGHT: 22px; BORDER-TOP: #e7ecf0 1px solid; CURSOR: pointer; BORDER-RIGHT: #e7ecf0 1px solid } #page .fk { WIDTH: 24px; BACKGROUND: url(http://s1.bdstatic.com/r/www/cache/global/img/bg-1.1.0.png) no-repeat -35px -309px; HEIGHT: 30px; CURSOR: pointer } #page STRONG .fk { CURSOR: auto } #page STRONG .pc { CURSOR: auto } #page .fkd { BACKGROUND-POSITION: -35px -303px } #page .fk_cur { BACKGROUND-POSITION: 2px -312px } #page STRONG .pc { LINE-HEIGHT: 24px; BORDER-RIGHT-WIDTH: 0px; WIDTH: 24px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; HEIGHT: 24px; BORDER-LEFT-WIDTH: 0px } #page .nums { DISPLAY: inline-block; VERTICAL-ALIGN: text-bottom } #rs { PADDING-BOTTOM: 8px; MARGIN: 20px 0px 0px; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; BACKGROUND: #fff; PADDING-TOP: 8px } #rs TD { WIDTH: 5% } #rs TH { TEXT-ALIGN: left; LINE-HEIGHT: 19px; WHITE-SPACE: nowrap; FONT-SIZE: 14px; VERTICAL-ALIGN: top; FONT-WEIGHT: normal } #rs .tt { PADDING-BOTTOM: 0px; PADDING-LEFT: 20px; PADDING-RIGHT: 10px; FONT-WEIGHT: bold; PADDING-TOP: 0px } #rs_top { MARGIN-BOTTOM: 22px; FONT-SIZE: 14px } #rs_top A { MARGIN-RIGHT: 18px } #search { PADDING-BOTTOM: 16px; PADDING-LEFT: 20px; PADDING-RIGHT: 0px; PADDING-TOP: 35px } #search .s_help { POSITION: relative; TOP: 10px } #foot { TEXT-ALIGN: center; LINE-HEIGHT: 20px; BACKGROUND: #e6e6e6; HEIGHT: 20px; COLOR: #77c } #foot SPAN { COLOR: #666 } .site_tip { PADDING-BOTTOM: 5px; LINE-HEIGHT: 18px; PADDING-LEFT: 72px; PADDING-RIGHT: 0px; MARGIN-BOTTOM: 20px; BACKGROUND: url(http://s1.bdstatic.com/r/www/img/bg-1.0.0.gif) no-repeat; FONT-SIZE: 13px; PADDING-TOP: 3px } .to_zhidao { PADDING-BOTTOM: 0px; LINE-HEIGHT: 24px; MARGIN: 20px 0px 0px; PADDING-LEFT: 32px; PADDING-RIGHT: 0px; BACKGROUND: url(http://s1.bdstatic.com/r/www/img/bg-1.0.0.gif) no-repeat 0px -68px; FONT-SIZE: 16px; PADDING-TOP: 0px } .to_tieba { PADDING-BOTTOM: 0px; LINE-HEIGHT: 24px; MARGIN: 20px 0px 0px; PADDING-LEFT: 32px; PADDING-RIGHT: 0px; BACKGROUND: url(http://s1.bdstatic.com/r/www/img/bg-1.0.0.gif) no-repeat 0px -68px; FONT-SIZE: 16px; PADDING-TOP: 0px } .to_tieba { BACKGROUND-POSITION: 0px -102px } .f { LINE-HEIGHT: 120%; WIDTH: 33.7em; WORD-WRAP: break-word; FONT-SIZE: 100%; WORD-BREAK: break-all } .h { WIDTH: 100%; MARGIN-LEFT: 8px } .r { WIDTH: 238px; WORD-BREAK: break-all; CURSOR: hand } .t { FONT-SIZE: medium; FONT-WEIGHT: normal } .pl { PADDING-LEFT: 3px; PADDING-RIGHT: 2px; HEIGHT: 8px; FONT-SIZE: 14px } .mo { LINE-HEIGHT: 10px; COLOR: #666; FONT-SIZE: 100% } A.mo:link { LINE-HEIGHT: 10px; COLOR: #666; FONT-SIZE: 100% } A.mo:visited { LINE-HEIGHT: 10px; COLOR: #666; FONT-SIZE: 100% } .htb { MARGIN-BOTTOM: 5px } .jc A { COLOR: #cc0000 } A FONT[size='3'] FONT { TEXT-DECORATION: underline } FONT[size='3'] A FONT { TEXT-DECORATION: underline } DIV.blog { COLOR: #707070; PADDING-TOP: 3px } DIV.bbs { COLOR: #707070; PADDING-TOP: 3px } .result { WIDTH: 33.7em; TABLE-LAYOUT: fixed } .result-op .f { WORD-WRAP: normal } .nums { COLOR: #999; FONT-SIZE: 12px } .tools { POSITION: absolute; WIDTH: 230px; WHITE-SPACE: nowrap; TOP: 10px } #mHolder { Z-INDEX: 296; POSITION: relative; WIDTH: 62px; DISPLAY: none; MARGIN-LEFT: 9px; TOP: -18px; MARGIN-RIGHT: -12px } #mCon { POSITION: absolute; PADDING-BOTTOM: 0px; LINE-HEIGHT: 18px; PADDING-LEFT: 0px; PADDING-RIGHT: 18px; BACKGROUND: url(http://s1.bdstatic.com/r/www/img/bg-1.0.0.gif) no-repeat right -135px; HEIGHT: 18px; TOP: 6px; CURSOR: pointer; RIGHT: 7px; PADDING-TOP: 0px } #mCon SPAN { DISPLAY: block; COLOR: #00c; CURSOR: default } #mCon .hw { CURSOR: pointer; TEXT-DECORATION: underline } #mMenu { BORDER-BOTTOM: #9b9b9b 1px solid; POSITION: absolute; BORDER-LEFT: #9b9b9b 1px solid; WIDTH: 56px; DISPLAY: none; BACKGROUND: #fff; BORDER-TOP: #9b9b9b 1px solid; TOP: 23px; RIGHT: 7px; BORDER-RIGHT: #9b9b9b 1px solid } #mMenu A { FILTER: none; LINE-HEIGHT: 22px; TEXT-INDENT: 6px; WIDTH: 100%; DISPLAY: block; HEIGHT: 100%; COLOR: #00c; TEXT-DECORATION: none } #mMenu A:hover { BACKGROUND: #ebebeb } #mMenu .ln { LINE-HEIGHT: 1px; MARGIN-TOP: -1px; BACKGROUND: #ebebeb; HEIGHT: 1px; FONT-SIZE: 1px; OVERFLOW: hidden } .op_LAMP { WIDTH: 16px; ZOOM: 1; DISPLAY: inline-block; BACKGROUND: url(http://s1.bdstatic.com/r/www/cache/global/img/aladdinIcon-1.0.gif) no-repeat 0px 2px; HEIGHT: 14px; COLOR: #77c; FONT-SIZE: 13px; TEXT-DECORATION: none } .EC_mr15 { MARGIN-LEFT: 0px } .pd15 { PADDING-LEFT: 0px } .map_1 { LINE-HEIGHT: 145%; WIDTH: 30em; FONT-SIZE: 80% } .map_2 { LINE-HEIGHT: 145%; WIDTH: 25em; FONT-SIZE: 80% } .favurl { PADDING-LEFT: 20px; BACKGROUND-REPEAT: no-repeat; BACKGROUND-POSITION: 0px 1px } .dan_tip { MARGIN-TOP: 4px; FONT-SIZE: 12px } .unsafe_txttip_o { LINE-HEIGHT: 19px; PADDING-LEFT: 18px; WIDTH: 31px; DISPLAY: inline-block; BACKGROUND: url(http://www.baidu.com/cache/global/img/bg-1.0.12.png) no-repeat left -762px; HEIGHT: 18px; COLOR: #fff; FONT-SIZE: 12px; CURSOR: pointer; MARGIN-RIGHT: 4px } .dan_tip A { COLOR: #b95b07 } #more { FILTER: progid:DXImageTransform.Microsoft.Shadow(Strength=2,Direction=135,Color="#cccccc"); box-shadow: 1px 1px 2px #ccc; -moz-box-shadow: 1px 1px 2px #ccc; -webkit-box-shadow: 1px 1px 2px #ccc } #u UL { FILTER: progid:DXImageTransform.Microsoft.Shadow(Strength=2,Direction=135,Color="#cccccc"); box-shadow: 1px 1px 2px #ccc; -moz-box-shadow: 1px 1px 2px #ccc; -webkit-box-shadow: 1px 1px 2px #ccc } #mMenu { FILTER: progid:DXImageTransform.Microsoft.Shadow(Strength=2,Direction=135,Color="#cccccc"); box-shadow: 1px 1px 2px #ccc; -moz-box-shadow: 1px 1px 2px #ccc; -webkit-box-shadow: 1px 1px 2px #ccc } .msg_holder { FILTER: progid:DXImageTransform.Microsoft.Shadow(Strength=2,Direction=135,Color="#cccccc"); box-shadow: 1px 1px 2px #ccc; -moz-box-shadow: 1px 1px 2px #ccc; -webkit-box-shadow: 1px 1px 2px #ccc } .hit_top { LINE-HEIGHT: 18px; MARGIN: 0px 15px 10px 0px; PADDING-LEFT: 20px; WIDTH: 516px; BACKGROUND: url(http://www.baidu.com/cache/global/img/bg-1.1.0.png) no-repeat left -619px } .hit_top_01 { LINE-HEIGHT: 20px; PADDING-LEFT: 0px; WIDTH: 33.7em; BACKGROUND: 0px 50% } .hit_top_01 I { WIDTH: 16px; DISPLAY: inline-block; BACKGROUND: url(http://www.baidu.com/cache/global/img/bg-1.1.0.png) no-repeat left -446px; HEIGHT: 16px; VERTICAL-ALIGN: 1px; MARGIN-RIGHT: 3px; _vertical-align: 2px } .f A FONT[size='3'] FONT { TEXT-DECORATION: underline } .f FONT[size='-1'] A FONT { TEXT-DECORATION: underline } H3 A FONT { TEXT-DECORATION: underline } .c-title { FONT-SIZE: 16px; FONT-WEIGHT: normal } .c-title-size { FONT-SIZE: 16px } .c-abstract { FONT-SIZE: 13px } .c-abstract-size { FONT-SIZE: 13px } .c-showurl { COLOR: #008000; FONT-SIZE: 13px } .c-showurl-color { COLOR: #008000 } .c-cache-color { COLOR: #666 } .c-lightblue { COLOR: #77c } .c-highlight-color { COLOR: #c00 } .c-clearfix:after { DISPLAY: block; HEIGHT: 0px; VISIBILITY: hidden; CLEAR: both; CONTENT: "." } .c-clearfix { ZOOM: 1 } .c-wrap { WORD-WRAP: break-word; WORD-BREAK: break-all } .icp_info { MARGIN-TOP: 3px; COLOR: #666 } .icp_info SPAN { WIDTH: 11px; DISPLAY: inline-block; BACKGROUND: url(http://www.baidu.com/cache/global/img/bg-1.1.0.png) -28px -223px; HEIGHT: 13px; VERTICAL-ALIGN: 2px; MARGIN-RIGHT: 5px } .icon-gw { LINE-HEIGHT: 16px; MARGIN: 4px 0px 0px; PADDING-LEFT: 18px; WIDTH: 31px; DISPLAY: inline-block; BACKGROUND: url(http://www.baidu.com/cache/global/img/bg-1.0.12.png) no-repeat left -793px; HEIGHT: 17px; COLOR: #fff; FONT-SIZE: 12px; VERTICAL-ALIGN: middle; OVERFLOW: hidden; PADDING-TOP: 1px } #con-at { MARGIN-BOTTOM: 15px } #con-ar { BORDER-LEFT: #e1e1e1 1px solid; PADDING-LEFT: 10px } #con-at .result-op { LINE-HEIGHT: 1.52em; MARGIN-BOTTOM: 15px; FONT-SIZE: 13px } #con-ar .result-op { LINE-HEIGHT: 1.52em; MARGIN-BOTTOM: 15px; FONT-SIZE: 13px }
6. 完整代码参考下载
包括schema.xml配置文件供参考用,下载地址:http://files.cnblogs.com/nayitian/solr_jsp.rar