0
try {

    PaperDAOImpl objPaperDAOImpl = new PaperDAOImpl();
    AuthorDAOImpl objAuthorDAOImpl = new AuthorDAOImpl();
    List<papersBean> listPaperBean = new ArrayList<papersBean>();
    List<List<Author>> listOfListAuthor = new ArrayList<List<Author>>();

    String title = null;
    String author = null;

    if (request.getParameter("searchtitle") != null) {
        title = request.getParameter("title").trim();
        if (title.trim().equals("")) {
            String error = " You must choice option search";
            request.setAttribute("error", error);

        } else {
            listPaperBean = objPaperDAOImpl.SearchPaperByTitle(title
                    .trim());
            request.setAttribute("listresult", listPaperBean);
            // Get List Author Name , List

            if (!listPaperBean.isEmpty()) {

                for (int i = 0; i < listPaperBean.size(); i++) {
                    List<Author> listAuthor = objAuthorDAOImpl
                            .GetListAuthorByIdPaper(listPaperBean
                                    .get(i).getIdPaper());
                    if (listAuthor != null) {
                        listOfListAuthor.add(listAuthor);
                    }
                }
                int size = 0; // for debug
                size = listOfListAuthor.size(); // for debug

                request.setAttribute("lolAuthor", listOfListAuthor);
                RequestDispatcher rd = request
                        .getRequestDispatcher("front-end/search.jsp");
                rd.forward(request, response);
                return;

            }
        }
    }

} catch (ServletException e) {
    e.printStackTrace();
}

finally {

}

这是用于搜索数据的 MyServlet。

当我调试到 util 行时:

 `RequestDispatcher rd = request.getRequestDispatcher("front-end/search.jsp");`  

一切还好。并且 "listOfListAuthor" , "listPaperBean"有数据......但是当调试到 row 时:

rd.forward();---> 我有一个问题我仍然无法解决。

**Aug 19, 2012 3:48:52 PM org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.IllegalStateException
at managerpapers.system.servletController.FESearchTitle.processRequest(FESearchTitle.java:73)--This is rows : `rd.forward()`;**

这是用于搜索数据的 MyServlet!我为此调试了一整天。这是我的论文。A 不了解 servlet master 。有人有什么主意吗 ?

这是用于搜索数据的 MyServlet!我为此调试了一整天。这是我的论文。A 不了解 servlet master 。有人有什么主意吗 ?

4

1 回答 1

0

正如Javadoc servletContext 的requestDispatcher 中所说,必须以“/”开头,并被解释为相对于当前上下文根。
所以而不是:
RequestDispatcher rd = request.getRequestDispatcher("front-end/search.jsp");

尝试这个 :
RequestDispatcher rd = request.getRequestDispatcher("/front-end/search.jsp");

我希望它会帮助你

于 2012-08-19T09:45:42.443 回答