DingDangDog 2018-11-24 01:15 采纳率: 0%
浏览 1143
已结题

javaweb转发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条回答 默认 最新

  • weixin_43785877 2018-11-24 01:18
    关注

    你这个软件有问题的,你要重新安装就好了,

    评论

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 7月27日

悬赏问题

  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划