📄 u01d41action.java
字号:
package cn.hope.front.action;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.log4j.Logger;
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 cn.hope.front.bo.U01Dbo;
import cn.hope.front.form.U01D4form;
import cn.hope.front.pojo.Student;
public class U01D41action extends Action{
Logger log = Logger.getLogger(U01D41action.class.getName());
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
U01D4form dyform = (U01D4form) form;
String name = (String)dyform.getName();
U01Dbo u01dbo=new U01Dbo();
List list=null;
Student student=null;
list=u01dbo.U01D4bo(name);
System.out.println(name);
//如果为真就返正确的页面
HttpSession session=request.getSession();
if(list!=null){
if(list.size()>0){ //放到实体中去
student =(Student) list.get(0);
session.setAttribute("D4",student);//把实体压倒SESSION里去。
}
}
if (list==null||list.size()==0) {//为空就是失败。
ActionMessages errors = new ActionMessages();
errors.add(ActionMessages.GLOBAL_MESSAGE,
new ActionMessage("U01label.deny"));
if (!errors.isEmpty()) {
saveErrors(request, errors);
}
return mapping.findForward("failed"); //登陆失败
}
else{
return mapping.findForward("D41");//登陆成功
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -