📄 addteacheraction.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.HashSet;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.AddTeacherForm;/** * MyEclipse Struts Creation date: 11-12-2005 * * XDoclet definition: * * @struts.action path="/addTeacher" name="addTeacherForm" * input="addTeacher.jsp" scope="request" validate="true" */public class AddTeacherAction 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) { AddTeacherForm addTeacherForm = (AddTeacherForm) form; String password = ""; String age = ""; String title = ""; String address = ""; String telephone = ""; String username = ""; String email = ""; String sex = ""; String name = ""; Long classes_id=null; if (addTeacherForm != null) { try { password = addTeacherForm.getPassword(); age = addTeacherForm.getAge(); title = new String((addTeacherForm.getTitle()) .getBytes("ISO-8859-1")); address = new String((addTeacherForm.getAddress()) .getBytes("ISO-8859-1")); telephone = addTeacherForm.getTelephone(); username = new String((addTeacherForm.getUsername()) .getBytes("ISO-8859-1")); email = addTeacherForm.getEmail(); sex = new String((addTeacherForm.getSex()) .getBytes("ISO-8859-1")); name = new String((addTeacherForm.getName()) .getBytes("ISO-8859-1")); classes_id=addTeacherForm.getClasses_id(); } catch (Exception e) { } } Teacher teacher = new Teacher(username,name,password,sex, title,age,telephone,email, address,new HashSet<hibernate.Student>(),new Classes(classes_id)); HibernateUtil.save(teacher); return (mapping.findForward(Constants.FORWARD_SUCCESS)); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -