如何在List或网格中或在Jsp中的表中显示数据

时间:2013-06-21 05:14:26

标签: javascript jsp

这是我的JSP代码:

<%@page import="java.util.Calendar"%> <%@ 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."%>

<% //out.print("Today is:"+Calendar.getInstance().getTimeInMillis());

String fil = "E:\\cbdtindex";
Analyzer analyzer = new SnowballAnalyzer("English");

IndexSearcher indexSearcher;

String[] fields = { "DocType1" };

try {
    // Directory indexDir = FSDirectory.open(findexfile);

    IndexReader reader = IndexReader.open(
            FSDirectory.open(new File(fil)), true);

    indexSearcher = new IndexSearcher(reader);
    MultiFieldQueryParser parser = new MultiFieldQueryParser(
            fields, analyzer);

    Query query = parser.parse("dtl");

    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 p = hitDoc.get("FilePath");
        //System.out.println(p);
        out.println(p);

    }

    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();
}
%>

我想在List Gird或Table中显示字符串P值。

有人能帮助我吗?我可以在控制台上的out.print.ln打印显示数据,但我需要在列表中显示。

1 个答案:

答案 0 :(得分:0)

您可以使用jstl <c:forEach>进行迭代,使用html <table><tr><td></td></tr></table>进行文本格式设置。最好只使用jsp作为视图而不使用scriptlet。