エラーorg.apache.jasper.JasperException:java.lang.NullPointerException
Error Org Apache Jasper
jsp pageを実行すると、次のエラーが発生します。急いで、2日間従事してください、本当に方法はありません! ! !偉大な神は一見を望むことができます! ! !
jarパッケージなので、jarパッケージをweb-INF libの下に配置する必要があるのか、それとも別のライブラリを作成する必要があるのかわかりません。私は別のものを作るためにここにいます、私たちは試みました。繰り返しの問題はないはずです。
次に、行エラーがあります。問題のコードは次のようになります。次に、
org.apache.jsp.result_jsp._jspService(result_jsp.java:91)
コードが間違っている場合は、91または次の行を今すぐに表示する必要がありますか? ?知りませんでした
次のソースを投稿しました
result.jsp
<%@ page language='java' contentType='text/html charset=UTF-8'
pageEncoding = 'UTF-8'%>
<%
String query =(String)request.getAttribute( 'query')
リストリスト= new ArrayList()
list =(List)request.getAttribute( 'docList')
int totalDocs =(整数)request.getAttribute( 'totalDocs')
double time = Double.parseDouble(request.getAttribute( 'time')。toString())
int pageNow =(Integer)request.getAttribute( 'pageNow')
int pageCount =(Integer)request.getAttribute( 'pageCount')
%>
の検索結果
window.onload = function(){
document.getElementById( 'query')。value = ''
}
発見された 結果|使用時class = 'newsnum'>秒
<%
if(list.size()> 0){
イテレータiter = list.iterator()
ドキュメントドキュメント
while(iter.hasNext()){
docs = iter.next()
%>
300? docs.getContent()。substring(0、300):docs.getContent()%>
-------------------------------------------------- --------
<%
}
}
%>
- ホームホーム
<%
if(pageNow!= 1){
%> - 前
<%
}
%>
<%
for(int i = 1 i<= pageCount i++) {
%>
- 次
- 最終
<%
}
%>
<%
}
%>
<%
if(pageNow!= pageCount){
%>
SearchServlet .java
パブリッククラスSearchServletはHttpServletを拡張します{
private static final long serialVersionUID = 1L
private static int totalDocs = 0
private static final int PAGE_SIZE = 10
private int pageCount = 1
private int rowCount = 1
private int pageNow = 1
プライベート静的文字列searchpath = 'F:\ index'
public void doPost(HttpServletRequest request、HttpServletResponse response)throws ServletException、IOException {
文字列query = request.getParameter( 'query')
System.out.println( 'クエリ' +クエリ)
long starTime = System.currentTimeMillis()
if(! ''。equals(query)&& query!= null){
ArrayList docList = getSearch(クエリ)
文字列temp_pageNow = request.getParameter( 'pagNow')
if(temp_pageNow!= null){
pageNow = Integer.parseInt(temp_pageNow)
}
rowCount = totalDocs
pageCount =(rowCount-1)/ PAGE_SIZE + 1
リストpagelist = docList.subList(PAGE_SIZE *(pageNow-1)、PAGE_SIZE * pageNow
if(docList.size()!= 0){
request.setAttribute( 'query'、query)
request.setAttribute( 'docList'、pagelist)
request.setAttribute( 'totalDocs'、totalDocs)
long endTime = System.currentTimeMillis()
長い時間= endTime-starTime
request.setAttribute( 'time'、(double)Time / 1000)
request.setAttribute( 'pageNow'、pageNow)
request.setAttribute( 'pageCount'、pageCount)
//request.setAttribute('highlighter'、highlighter)
request.getRequestDispatcher( 'result.jsp')。forward(request、response)
}そうしないと {
request.getRequestDispatcher( 'error.jsp')。forward(request、response)
}
}
}
プライベート静的ArrayListgetSearch(Stringキーワード){
ArrayList docList = new ArrayList()
DirectoryReader directoryReader = null
{を試してください
ディレクトリdirectory = FSDirectory.open(new File(searchpath))
directoryReader = DirectoryReader.open(directory)
IndexSearcher indexSearcher = new IndexSearcher(directoryReader)
アナライザーanalyzer = new IKAnalyzer()
QueryParser queryParser = new QueryParser(Version.LUCENE_46、 'content'、analyzer)
クエリquery = queryParser.parse(keyword)
TopDocs topDocs = indexSearcher.search(query、500)
totalDocs = topDocs.totalHits
System.out.println( 'ドキュメントの合計検索数:' + totalDocs)
ScoreDoc [] scoreDocs = topDocs.scoreDocs
for(int i = 0i
ドキュメントdocument = indexSearcher.doc(scoreDocs [i] .doc)
System.out.println( '[' + i + ']' + document.get( 'title'))
System.out.println(document.get( 'link'))
System.out.println( 'score:' + scoreDocs [i] .score)
Docs docs = new Docs(document.get( 'title')、document.get( 'link')、
document.get( 'content')、totalDocs)
docList.add(docs)
}
} catch(IOException e){
// TODO自動生成されたcatchブロック
e.printStackTrace()
} catch(ParseException e){
// TODO自動生成されたcatchブロック
e.printStackTrace()
}
docListを返す
}
protected void doGet(HttpServletRequest request、HttpServletResponse response)throws ServletException、IOException {
doPost(リクエスト、レスポンス)
}
//テスト
public static void main(String [] args){
ArrayList docList = new ArrayList()
docList =(ArrayList)getSearch( 'ヘルプ')
}
テスト結果はわかっていますが、jspが開いていないか、データがjspに渡されていませんか? ?