⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uniquecheckservlet.java

📁 基于SSH (struts+spring+hibernate)框架设计的 CRM客户关系管理系统
💻 JAVA
字号:
package com.csu.crm.common.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.web.context.WebApplicationContext;

import com.csu.crm.common.dao.SingleObjectDAO;
/**
 * 此类用于ajax后台调用,用于检测 文本域输入的字符 在 对应表里是否已经存在,如果存在就提示 此名字已被占用
 * 
 * @author 3eCRM小组:曾东
 * @since 2007-9-30 下午04:21:31
 * @version 1.0 创建时间:2007-9-30 下午04:21:31,初始版本
 */
public class UniqueCheckServlet extends HttpServlet {
	private SingleObjectDAO singleObjectDAO;
	public SingleObjectDAO getSingleObjectDAO() {
		return singleObjectDAO;
	}
	public void setSingleObjectDAO(SingleObjectDAO singleObjectDAO) {
		this.singleObjectDAO = singleObjectDAO;
	}
	/**
	 * Constructor of the object.
	 */
	public UniqueCheckServlet() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	/**
	 * The doGet method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to get.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {		
		request.setCharacterEncoding("gb2312");
		response.setCharacterEncoding("gb2312");
		response.setContentType("text/html; charset=gb2312");
		
//		Enumeration e = this.getServletContext().getAttributeNames();
//		while(e.hasMoreElements()) {
//			System.out.println(e.nextElement());
//		}
		
		String para ="org.springframework.web.struts.ContextLoaderPlugIn.CONTEXT.";
		WebApplicationContext wac = (WebApplicationContext)this.getServletContext().getAttribute(para);
		
		singleObjectDAO = (SingleObjectDAO)wac.getBean("SingleObjectDAO");
		
		String value = request.getParameter("value");
		String vo = request.getParameter("vo");
		String property = request.getParameter("property");
		
		value = new String(value.getBytes("ISO-8859-1"), "gb2312");
//		System.out.println("@@@@@@@@"+value);
		PrintWriter out=response.getWriter();
		
//		if(singleObjectDAO.isExisted("CrmCustomer", "enterprise", value)) {
		if(singleObjectDAO.isExisted(vo,property, value)) {
			out.write("fail");
		}else {
			out.write("pass");
		}		
		out.close();
	}

	/**
	 * The doPost method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to post.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doGet(request,response);
	}

	/**
	 * Initialization of the servlet. <br>
	 *
	 * @throws ServletException if an error occure
	 */
	public void init() throws ServletException {
		// Put your code here
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -