stuaction.java

来自「本程序为Java软件开发中」· Java 代码 · 共 55 行

JAVA
55
字号
package cn.stu;

import java.util.ArrayList;

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

import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import cn.dao.UserinfoDatabase;
import cn.login.PJBaseAction;
import cn.login.PJBaseForm;

public class StuAction extends PJBaseAction {

	@Override
	public ActionForward doAction(ActionMapping mapping, PJBaseForm form, HttpServletRequest req, HttpServletResponse res) throws Exception {
		ActionForward moveTo = mapping.getInputForward();
		StuForm myform = (StuForm)form;
		HttpSession s = req.getSession();
		
		
		ArrayList<String> loginInfo= (ArrayList) s.getAttribute("loginUser");
		if(loginInfo==null){
			moveTo=mapping.findForward("login");
		}else{
			if("tuichu".equals(myform.getActType())){
				s.removeAttribute("loginUser");
				moveTo=mapping.findForward("login");
			}else if("xiugai".equals(myform.getActType())){
				s.setAttribute("xiugai",loginInfo.get(0));
				
				moveTo=mapping.findForward("xiugai");
			}else{
				UserinfoDatabase ud = new UserinfoDatabase(myform.getConn());
				ArrayList<String> info = ud.select(loginInfo.get(0),loginInfo.get(1));
				myform.setUsername(info.get(0));
				myform.setPassword(info.get(1));
				myform.setSex(info.get(2));
				myform.setTel(info.get(3));
				myform.setMail(info.get(4));
				myform.setSchool(info.get(5));
				myform.setXingqu(info.get(6));
				myform.setJianjie(info.get(7));
			}
			
			
		}
		return moveTo;
	}

}

⌨️ 快捷键说明

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