0

これは私の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>

リストビューやグリッドビューで表示したい。私がどうするか助けてください。私はJSPが初めてです。朝からやってみたけど無理。

4

0 に答える 0