createst.java

来自「成绩查询系统(学校期末的作业) Struts+jdbc+mysql+tomca」· Java 代码 · 共 44 行

JAVA
44
字号
package sfs.struts.actions;

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 sfs.entity.Student;
import sfs.entity.io.StudentIo;
import sfs.struts.forms.CreateSTForm;
import sfs.tools.MD5;

public class CreateST extends Action {

	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		CreateSTForm cf=(CreateSTForm)form;
		Student te=new Student();
		MD5 md5=new MD5();
		StudentIo stio=new StudentIo();
		String id = null;
		te.setId(cf.getId());
		te.setAuthority(cf.getAuthority());
		te.setNumber(cf.getNumber());		
		String psd=cf.getPassword();
		if (psd==null&&id!="0") {
			Student temp=(Student) stio.queryByid(cf.getId()).get(0);
			te.setPassword(temp.getPassword());
		}else{			
			te.setPassword(md5.getMD5ofStr(cf.getPassword()));		
		}
		te.setRealname(cf.getRealname());
		te.setClassname(cf.getClassname());
		te.setDepartment(cf.getDepartment());
		stio.saveorupdata(te);
		return mapping.findForward("success");
	}

}

⌨️ 快捷键说明

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