使用重对象的,然后打开变成下载文件浏览了。。。啥问题呀,跪求解答

男汉纸 发布于 2016/06/17 13:45
阅读 55
收藏 0
package cn.itcast.web.servlet;


import java.io.IOException;
import java.util.ArrayList;
import java.util.List;


import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;




public class BuyServlet extends HttpServlet {




public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
 
String id = request.getParameter("id");
Book book = (Book) Db.getAll().get(id);
HttpSession session = request.getSession(false);

List list = (List) session.getAttribute("list");
if(list==null){
list = new ArrayList();
session.setAttribute("list",list);
}
list.add(book);

String url = response.encodeRedirectURL(request.getContextPath()+"/servlet/ListCarServlet");
response.sendRedirect(url);
}


public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {


doGet(request, response);
}


}

加载中
返回顶部
顶部