hoO丶
2018-11-24 01:15javaweb转发forward报错
工具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)
我觉得是编译器的原因,但是怎么都弄不好,求大佬们指点!!!
- 点赞
- 回答
- 收藏
- 复制链接分享
2条回答
为你推荐
- 使用jsp:forward跳转到另一个页面时乱码(不传参数)
- 乱码
- java
- 9个回答