如何在jsp中的List或Grid中显示数据

时间:2013-06-20 09:06:54

标签: javascript html jsp

这是我的action.jsp文件:

<%@page import="java.util.ArrayList"%>
<%@page import="java.util.Calendar"%>
<%@ page import="java.util.*"%>
<%@ page import="org.apache.lucene.search.IndexSearcher"%>
<%@ page import="org.apache.lucene.analysis.Analyzer"%>
<%@ page import="org.apache.lucene.analysis.snowball.SnowballAnalyzer"%>
<%@ page import="org.apache.lucene.search.Hits"%>
<%@ page import="org.apache.lucene.queryParser.QueryParser"%>
<%@ page import="org.apache.lucene.queryParser.MultiFieldQueryParser"%>
<%@ page import="org.apache.lucene.queryParser.ParseException"%>
<%@ page import="org.apache.lucene.queryParser.QueryParser"%>
<%@ page import="org.apache.lucene.search.Query"%>
<%@ page import="org.apache.lucene.util.Version"%>
<%@ page import="org.apache.lucene.store.FSDirectory"%>
<%@ page import="org.apache.lucene.search.ScoreDoc"%>
<%@ page import="org.apache.lucene.document.Document"%>
<%@ page import="org.apache.lucene.search.ScoreDoc"%>
<%@ page import="org.apache.lucene.index.IndexReader"%>
<%@ page import="java.io.IOException"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1" import="java.io.*, java.net.*"%>   

<html>
    <head>
           <title>Using GET and POST Method to Read Form Data</title>
    </head>
    <body>
     <%
       String k = request.getParameter("first_name");
       //out.println(k);

       String fil = "E:\\cbdtindex";

       Analyzer analyzer = new SnowballAnalyzer("English");

       IndexSearcher indexSearcher;
       String[] fields = { "DIG" };
       try {
          IndexReader reader = IndexReader.open(FSDirectory.open(new File(fil)), true);
          indexSearcher = new IndexSearcher(reader);
          MultiFieldQueryParser parser = new MultiFieldQueryParser(fields, analyzer);
          Query query = parser.parse(k);
          ScoreDoc[] hits = indexSearcher.search(query, null, 100000).scoreDocs;
          int x = hits.length;
          for (int i = 0; i < x; i++) {
            Document hitDoc = indexSearcher.doc(hits[i].doc);
            String d = hitDoc.get("Description");
            String p = hitDoc.get("FilePath");
            out.println(d + "<br>");
            }
          System.out.println("Length" + x);
         } catch (IOException e) {
         // TODO Auto-generated catch block
           e.printStackTrace();
         } catch (ParseException e) {
         // TODO Auto-generated catch block
           e.printStackTrace();
        }
 %>
  </p>
 </body>
</html>

index.html

<html>
  <body>
    <form action="action.jsp" method="POST">
    Text Search : <input type="text" name="first_name"> <br /> <input
    type="submit" value="Submit" />
   </form>
  </body>
</html>

我想在Listview或Gridview中显示它。请帮助我如何做。我是JSP的新手。我从早上开始尝试但是无法做到。

0 个答案:

没有答案