工具eclipse——本意是通过filter过滤,如下:
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
HttpServletRequest req = (HttpServletRequest) request;
if (req.getSession().getAttribute("hotproductlist") != null) {
chain.doFilter(req, response);
} else {
req.getRequestDispatcher(req.getContextPath() + "/findHotProduct").forward(req, response);
}
}
这里一切正常,但是servlet的forward报错:
public void doGet(HttpServletRequest request, HttpServletRequest response) throws ServletException, IOException {
ProductService service=new ProductService();
List<Product> hotproductlist=new ArrayList<Product>();
hotproductlist=service.findHotProduct();
request.getSession().setAttribute("hotproductlist", hotproductlist);
request.getRequestDispatcher(request.getContextPath()+"/index.jsp").forward(request, response);;
}
这里的forward报错The method forward(ServletRequest, ServletResponse) in the type RequestDispatcher is not applicable for the arguments (HttpServletRequest, HttpServletRequest)
我觉得是编译器的原因,但是怎么都弄不好,求大佬们指点!!!