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

📄 adminlogaction.java

📁 使用struts+spring+JDBC 实现的学生选课管理系统
💻 JAVA
字号:
package bit.jeffy.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;

import bit.jeffy.bean.AdminLoger;
import bit.jeffy.entity.Admin;
import bit.jeffy.service.AdminDao;

public class AdminLogAction extends Action{
	private AdminDao admindao;
	
	public ActionForward execute(ActionMapping map, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) throws Exception {
		// TODO 自动生成方法存根
		ActionMessages errors = new ActionMessages();
		
		String path = servlet.getServletContext().getRealPath("/WEB-INF/beans.xml");
		String rp = (String)request.getSession().getAttribute("path");
		if(rp != null){
			request.getSession().removeAttribute("path");
		}
		request.getSession().setAttribute("path",path);
		
		String username = (String)((AdminLoger)form).getZh();
		String password = (String)((AdminLoger)form).getPassword();
		username = new String(username.getBytes("ISO-8859-1"),"GB2312");
		password = new String(password.getBytes("ISO-8859-1"),"GB2312");

		if( username.equals("") || password.equals("")){
			errors.add("fail_1",new ActionMessage("AdminLogAction.a"));
			saveErrors(request,errors);
			return (map.getInputForward());
		}
		
		HttpSession session = request.getSession();
		Admin admin = new Admin();
		Admin ad = null;
		admin.setAdmin_no(username);
		admin.setPassword(password);
		String tmp = null;
		
		ad = admindao.read(admin);
		if( ad != null)
		{
			tmp = (String)session.getAttribute("curr_admin_zh");
			if( tmp == null)
			{
				session.setAttribute("curr_admin_id",new Long(ad.getId()));
				session.setAttribute("curr_admin_zh",username);
			}
			else
			{
				session.removeAttribute("curr_admin_id");
				session.removeAttribute("curr_admin_zh");
				session.setAttribute("curr_admin_id",new Long(ad.getId()));
				session.setAttribute("curr_admin_zh",username);
			}
			return (map.findForward("login"));
		}
		else
		{
			errors.add("fail_3",new ActionMessage("AdminLogAction.b"));
			saveErrors(request,errors);
			return (map.getInputForward());
		}
	}

	public AdminDao getAdmindao() {
		return admindao;
	}

	public void setAdmindao(AdminDao admindao) {
		this.admindao = admindao;
	}

}

⌨️ 快捷键说明

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