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

📄 logincheck.java

📁 MM7彩信对接网关示例
💻 JAVA
字号:
/*
 * Created on 2005-11-30
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package com.rainbow.util.login;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import org.hibernate.Session;

import com.opensymphony.webwork.ServletActionContext;
import com.opensymphony.xwork.ActionContext;
import com.opensymphony.xwork.ActionSupport;
import com.rainbow.util.tools.HibernateUtil;

/**
 * 校验用户登录信息, 如果登录成功, Session里面的IsLogin字段是yes, 否则是no
 * @author Rainbow MMS Platform Leader -- TrWorks
 */
public class LoginCheck extends ActionSupport {

	private static final long serialVersionUID = 1L;

	/**
	 * 
	 */
	public LoginCheck() {
		super();
	}

	/**
	 * 登陆判断
	 */
	public String execute() throws Exception {
		
		String userName = ServletActionContext.getRequest().getParameter("userName");
		String password = ServletActionContext.getRequest().getParameter("password");
		String role = ServletActionContext.getRequest().getParameter("role");
		
		try{
			Session sess = HibernateUtil.currentSession();
			Connection con = sess.connection();
			PreparedStatement s = con.prepareStatement("select tnId from MMS_TSysPlatformUserManage where tcUserName = ? and tcPassword = ? and tnRole = ?");

			s.setString(1, userName);
			s.setString(2, password);
			s.setInt(3, Integer.parseInt(role));
			
			ResultSet set = s.executeQuery();
			if (set.next()){
				ActionContext.getContext().getSession().put("IsLogin", "yes");
				return SUCCESS;
			}
			else{
				ActionContext.getContext().getSession().put("IsLogin", "no");
				return SUCCESS;
			}
		}
		catch(Exception e1){
			e1.printStackTrace();
		}
		finally{
			HibernateUtil.closeSession();
		}
		
		return ERROR;
	}
}

⌨️ 快捷键说明

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