示例#1
0
  @Override
  protected void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    Map<String, Object> outMap = new HashMap<String, Object>();
    outMap.put(Constant.RESPONSE, "hotproduct");
    List<Product> productlist = new ArrayList<Product>();

    for (int i = 0; i < 10; i++) {
      Product vo =
          new Product(
              10000 + i, "雅戈�?" + i, 1000.00 + i, 800.00, Constant.pic_url.concat("image10.png"));
      productlist.add(vo);
    }
    outMap.put("productlist", productlist);
    outMap.put("list_count", productlist.size());
    CommonUtil.renderJson(resp, outMap);
  }
示例#2
0
 public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
     throws IOException, ServletException {
   HttpServletRequest req = (HttpServletRequest) request;
   HttpServletResponse resp = (HttpServletResponse) response;
   req.getSession();
   req.getSession().getId();
   String substring = req.getRequestURI().substring(req.getContextPath().length());
   if (urls.contains(substring)) {
     if (req.getSession().getAttribute("user") == null) {
       Map<String, Object> outMap = new HashMap<String, Object>();
       outMap.put(Constant.RESPONSE, "notlogin");
       CommonUtil.renderJson(resp, outMap);
       return;
     }
   }
   chain.doFilter(request, response);
 }