Package com.lgx8.common.servlet

Source Code of com.lgx8.common.servlet.InitProvinceCityCountyServlet

package com.lgx8.common.servlet;

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

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.management.dao.IDictionaryDao;
import com.lgx8.management.entities.Dictionary;
import com.lgx8.right.common.StringUtil;

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

  /**
   * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
   */
  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    doPost(request, response);
  }

  /**
   * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
   */
  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    request.setCharacterEncoding("UTF-8");
    response.setCharacterEncoding("UTF-8");
   
    String kind = request.getParameter("kind");
    String code = request.getParameter("code");
   
    ApplicationContext ac = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
    IDictionaryDao dao = (IDictionaryDao) ac.getBean("dictionaryDao");
   
   
    List<Dictionary> dictionarys = dao.listByKindAndCode(kind, code);
   
    String str = "";
   
    for(Dictionary d : dictionarys)
    {
      if(!StringUtil.isEmptyStr(str)) str += "|";
      str += d.getCODE()+","+d.getDETAIL();
    }
    PrintWriter out = response.getWriter();
    out.print(str);
   
  }

}
TOP

Related Classes of com.lgx8.common.servlet.InitProvinceCityCountyServlet

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.