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

📄 u03loginf1action.java

📁 持久层hibernate技术使用的一个例子
💻 JAVA
字号:
package cn.hope.front.action;


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

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 org.apache.struts.actions.DispatchAction;
import org.apache.struts.validator.DynaValidatorForm;

import cn.hope.front.bo.U03StudentBO;
import cn.hope.front.pojo.Student;
import cn.hope.front.util.Utility;

public class U03LoginF1Action extends DispatchAction {
	public ActionForward check(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		ActionMessages errors = new ActionMessages();
		try
		{   
			DynaValidatorForm u03UpdateInfoForm=(DynaValidatorForm)form;
		   	String strBirthday = u03UpdateInfoForm.get("data1").toString();
		   	String strInSchoolDate = u03UpdateInfoForm.get("data2").toString();
		   	Student student = (Student)u03UpdateInfoForm.get("student");
		   	student.setSNmd(Utility.stringToDate(strBirthday));
		   	student.setSStime(Utility.stringToDate(strInSchoolDate));
		   	request.getSession().setAttribute("studentInfo",student);
		   	return mapping.findForward("f10");
		}
		catch (Exception e) {
			log.error(e);
			e.printStackTrace();
			ActionMessage am = new ActionMessage(e.toString());
			errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(
					"errors.u07exception"));
			errors.add(ActionMessages.GLOBAL_MESSAGE, am);
			saveErrors(request, errors);
			return mapping.findForward("errorPage");
		}		
	}
	
	public ActionForward update(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
	throws Exception {
		ActionMessages errors = new ActionMessages();
		try{
			Student student = (Student)request.getSession().getAttribute("studentInfo");
			U03StudentBO u03StudentBO=new U03StudentBO();
			u03StudentBO.update(student);
			return mapping.findForward("success");
		}
		catch (Exception e) {
			log.error(e);
			e.printStackTrace();
			ActionMessage am = new ActionMessage(e.toString());
			errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(
					"errors.u07exception"));
			errors.add(ActionMessages.GLOBAL_MESSAGE, am);
			saveErrors(request, errors);
			return mapping.findForward("errorPage");
		}		
	}
}

⌨️ 快捷键说明

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