loginstaction.java
来自「这是一个可以让学生选择自己喜欢的课题」· Java 代码 · 共 124 行
JAVA
124 行
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.yourcompany.struts.action;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionErrors;
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 allBeans.LastStudentTittle;
import allBeans.StZhiyuan;
import allBeans.Students;
import allDAOFactory.IFirstStudentTittleDAO;
import allDAOFactory.ILastStudentTittleDAO;
import allDAOFactory.IStudentDAO;
import allDAOFactory.ITimecontrolDAO;
import allDAOFactory.ITittleDAO;
import com.yourcompany.struts.form.LoginstForm;
/**
* MyEclipse Struts
* Creation date: 07-29-2008
*
* XDoclet definition:
* @struts.action path="/loginst" name="loginstForm" input="/Students/loginst.jsp" scope="request" validate="true"
*/
public class LoginstAction extends Action {
/*
* Generated Methods
*/
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
LoginstForm loginstForm = (LoginstForm) form;// TODO Auto-generated method stub
IStudentDAO stdao=new IStudentDAO();
Students student=new Students();
student=stdao.stget(loginstForm.getUserid());
// System.out.println(student.getStId());
System.out.println(student.getStPassword());
if(student!=null && student.getStPassword().equals(loginstForm.getPassword()))
{
String st_id=student.getStId();
request.getSession().setAttribute("userID",st_id );
request.getSession().setAttribute("st_name", student.getStName());
ITimecontrolDAO tmdao=new ITimecontrolDAO();
Integer ntm=tmdao.tmcongetst();
String tm=String.valueOf(ntm);
request.getSession().setAttribute("tm", tm);
System.out.println(tm);
if(tm.equals("1"))
{
IFirstStudentTittleDAO fstdao=new IFirstStudentTittleDAO();
StZhiyuan stzhiyuanone=fstdao.fstget(st_id,"1");
StZhiyuan stzhiyuantwo=fstdao.fstget(st_id,"2");
StZhiyuan stzhiyuanthree=fstdao.fstget(st_id,"3");
request.setAttribute("stzhiyuanone", stzhiyuanone);
request.setAttribute("stzhiyuantwo", stzhiyuantwo);
request.setAttribute("stzhiyuanthree", stzhiyuanthree);
return mapping.findForward("tostfirstmain");
}
else if(tm.equals("2"))
{
ILastStudentTittleDAO lstdao=new ILastStudentTittleDAO();
StZhiyuan stzhiyuan=lstdao.lstgetzhiyuan(st_id);
request.setAttribute("stzhiyuan", stzhiyuan);
if(stzhiyuan==null)
{
request.setAttribute("prior", "4");
}
else
{
ITittleDAO tidao=new ITittleDAO();
String timemo=tidao.tiget(stzhiyuan.getTiid()).getTiMemo();
request.setAttribute("timemo", timemo);
request.setAttribute("prior", stzhiyuan.getPrior());
}
return mapping.findForward("tostsecondmain");
}
else if(tm.equals("3"))
{
ILastStudentTittleDAO lstdao=new ILastStudentTittleDAO();
StZhiyuan stzhiyuan=lstdao.lstgetzhiyuan(st_id);
request.setAttribute("stzhiyuan", stzhiyuan);
if(stzhiyuan!=null)
{
ITittleDAO tidao=new ITittleDAO();
String timemo=tidao.tiget(stzhiyuan.getTiid()).getTiMemo();
request.setAttribute("timemo", timemo);
}
return mapping.findForward("tostlookmain");
}
else
{
return mapping.getInputForward();
}
}
else
{
ActionErrors errors=new ActionErrors();
errors.add("loginstfailed",new ActionMessage("loginst.failed"));
this.addErrors(request, errors);
return mapping.getInputForward();
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?