Package com.lgx8.gateway.admin.servlet

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

package com.lgx8.gateway.admin.servlet;

import java.io.IOException;
import java.io.PrintWriter;

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.right.dao.IUserDao;
import com.lgx8.right.entities.User;

/**
* Servlet implementation class GetUserNameByMobileOrCardServlet
*/
public class GetUserNameByMobileOrCardServlet extends HttpServlet {
  private static final long serialVersionUID = 1L;

  /**
   * @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 {
    String params = request.getParameter("params");
   
    ApplicationContext ac = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
    IUserDao userDao = (IUserDao) ac.getBean("userDao");
   
    User user = userDao.getUserByMobileOrCard(params);
    response.setCharacterEncoding("UTF-8");
    PrintWriter pw = response.getWriter();
    if(user != null)
    {
      pw.write(user.getTruename() != null ? user.getTruename() : user.getUsername());
    }else
    {
      pw.write("0");
    }
  }

}
TOP

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

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.