Package com.lgx8.gateway.servlet

Source Code of com.lgx8.gateway.servlet.GatewayAdFristServlet

package com.lgx8.gateway.servlet;

import java.io.IOException;
import java.io.Writer;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

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

import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import com.lgx8.gateway.service.IGatewayService;
import com.lgx8.gateway.util.GatewayConstants;
import com.lgx8.gateway.vo.ProductVO;

import freemarker.template.Template;
import freemarker.template.TemplateException;

/**
* Servlet implementation class GatewayAdFristServlet
*/
public class GatewayAdFristServlet extends GatewayBaseServlet {
  private static final long serialVersionUID = 1L;
      
    /**
     * @see GatewayBaseServlet#GatewayBaseServlet()
     */
    public GatewayAdFristServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

  /**
   * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
   */
  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    Map<Object, Object> root = new HashMap<Object, Object>();
    root.putAll(super.root);
   
    Template temp = getConfiguration().getTemplate("adfirst.ftl");
   
    ApplicationContext ac = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
    IGatewayService gatewayService = (IGatewayService) ac.getBean("gatewayService");
   
    //通栏广告
    List<ProductVO> productVOs = gatewayService.initGatewayInfo(GatewayConstants.CID_TLGG);
   
    if(productVOs != null && productVOs.size() != 0)
    {
      root.put("productVOs", productVOs);
    }
   
    /* 将模板和数据模型合并 */
    Writer out = response.getWriter();
    try {
      temp.process(root, out);
    } catch (TemplateException e) {
      e.printStackTrace();
    }
    out.flush();
  }

}
TOP

Related Classes of com.lgx8.gateway.servlet.GatewayAdFristServlet

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.