在跟着视频在学习, 这里出现了问题 index页面中: <a href="/10JSP_Project/servlet/CollectionServlet?type=list">进入</a> CollectionServlet中: public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String type = (String) request.getAttribute("type"); System.out.println(type); //为什么输出值为null? if(type!=null && type.equals("save")){ save(request, response); }else if(type!=null && type.equals("list")){ list(request, response); }else { } } |
|
10分 |
String type = request.getParameter("type"); |
10分 |
getParameter,方法用错了,getAttribute只能取得setAttribute的值
|