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

📄 updateteacheraction.java

📁 这是一个用Struts+Hibernate+Tomcat5.5.9实现的一个“课程管理系统”
💻 JAVA
字号:
//Created by MyEclipse Struts// XSL source (default): platform:/plugin/com.genuitec.eclipse.cross.easystruts.eclipse_4.0.0/xslt/JavaClass.xslpackage struts.action;import hibernate.Classes;import hibernate.HibernateUtil;import hibernate.Teacher;import java.util.Iterator;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.ActionForm;import org.apache.struts.action.ActionForward;import org.apache.struts.action.ActionMapping;import struts.Constants;import struts.form.UpdateTeacherForm;/** * MyEclipse Struts Creation date: 11-14-2005 *  * XDoclet definition: *  * @struts.action path="/updateTeacher" name="updateTeacherForm" *                input="updateTeacher.jsp" scope="request" validate="true" */public class UpdateTeacherAction extends Action {	// --------------------------------------------------------- Instance	// Variables	// --------------------------------------------------------- Methods	/**	 * Method execute	 * 	 * @param mapping	 * @param form	 * @param request	 * @param response	 * @return ActionForward	 */	public ActionForward execute(ActionMapping mapping, ActionForm form,			HttpServletRequest request, HttpServletResponse response) {		UpdateTeacherForm updateTeacherForm = (UpdateTeacherForm) form;		String password = "";		String age = "";		String title = "";		String address = "";		String telephone = "";		String username = "";		String email = "";		String sex = "";		String name = "";		Long id = null;		Long classes_id=null;		if (updateTeacherForm != null) {			id = updateTeacherForm.getId();			classes_id=updateTeacherForm.getClasses_id();			try {				password = updateTeacherForm.getPassword();				age = updateTeacherForm.getAge();				title = new String((updateTeacherForm.getTitle())						.getBytes("ISO-8859-1"));				address = new String((updateTeacherForm.getAddress())						.getBytes("ISO-8859-1"));				telephone = updateTeacherForm.getTelephone();				username = new String((updateTeacherForm.getUsername())						.getBytes("ISO-8859-1"));				email = updateTeacherForm.getEmail();				sex = new String((updateTeacherForm.getSex())						.getBytes("ISO-8859-1"));				name = new String((updateTeacherForm.getName())						.getBytes("ISO-8859-1"));			} catch (Exception e) {			}		}		try {			List results = HibernateUtil.findTeacher(id);			Iterator it = results.iterator();			while (it.hasNext()) {				Teacher teacher = (Teacher) it.next();				teacher.setPassword(password);				teacher.setAge(age);				teacher.setTitle(title);				teacher.setAddress(address);				teacher.setTelephone(telephone);				teacher.setUsername(username);				teacher.setEmail(email);				teacher.setSex(sex);				teacher.setName(name);				teacher.setClasses(new Classes(classes_id));				HibernateUtil.update(teacher);			}		} catch (Exception e) {		}		return (mapping.findForward(Constants.FORWARD_SUCCESS));	}}

⌨️ 快捷键说明

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