findthreadaction.java

来自「Chinaxp 论坛源代码」· Java 代码 · 共 55 行

JAVA
55
字号
/* * XP Forum * * Copyright (c) 2002-2003 RedSoft Group.  All rights reserved. * */package org.redsoft.forum.web;import org.apache.lucene.queryParser.ParseException;import org.apache.struts.action.Action;import org.apache.struts.action.ActionForm;import org.apache.struts.action.ActionForward;import org.apache.struts.action.ActionMapping;import org.redsoft.forum.search.ThreadSearcher;import javax.servlet.ServletException;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import java.io.IOException;import java.util.Collection;/** * Find threads action * * @author cinc * @version $Id: FindThreadAction.java,v 1.1.1.1 2004/02/04 03:52:13 mustang Exp $ */public class FindThreadAction extends Action{    public ActionForward execute(ActionMapping mapping,				 ActionForm form,				 HttpServletRequest request,				 HttpServletResponse response)	throws IOException, ServletException {        ThreadSearcher searcher = ThreadSearcher.getInstance();        FindThreadForm findThreadForm = (FindThreadForm)form;        String query = findThreadForm.getQuery();        String type = findThreadForm.getType();        Collection threads = null;        try{            if (type.equals("title")){                threads = searcher.findByTitle(query);            }else if (type.equals("content")){                threads = searcher.findByContent(query);            }        }catch (ParseException e){            return (mapping.findForward("error"));        }        request.setAttribute("threads", threads);        request.setAttribute("query", query);        request.setAttribute("threadcount", "" + threads.size());        //request.setAttribute("offset", new Integer(2));        return (mapping.findForward("success"));    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?