Package com.lgx8.gateway.admin.servlet

Source Code of com.lgx8.gateway.admin.servlet.GatewayAdminSelectImageServlet

package com.lgx8.gateway.admin.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.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

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

import com.lgx8.common.entities.ProductImage;
import com.lgx8.gateway.service.IGatewayService;

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

/**
* Servlet implementation class GatewayAdminSelectImageServlet
*/
public class GatewayAdminSelectImageServlet extends GatewayAdminBaseServlet {
  private static final long serialVersionUID = 1L;
      
    /**
     * @see GatewayAdminBaseServlet#GatewayAdminBaseServlet()
     */
    public GatewayAdminSelectImageServlet() {
        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("selectImage.ftl");
   
    ApplicationContext ac = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
    IGatewayService gatewayService = (IGatewayService) ac.getBean("gatewayService");
   
    List<ProductImage> productImages = gatewayService.findProductImageListOrderByTime("desc");
   
    if(productImages!=null&&productImages.size()>0) {
      root.put("productImages", productImages);
    }
   
    /* 将模板和数据模型合并 */
    Writer out = response.getWriter();
    try {
      temp.process(root, out);
    } catch (TemplateException e) {
      e.printStackTrace();
    }
    out.flush();
  }

}
TOP

Related Classes of com.lgx8.gateway.admin.servlet.GatewayAdminSelectImageServlet

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.