modifyinfoaction.java

来自「struts在线考试系统. 自己还没看」· Java 代码 · 共 62 行

JAVA
62
字号
package com.lili.exam.action;

import org.apache.struts2.ServletActionContext;

import com.lili.common.exception.ExamException;
import com.lili.exam.pojo.Student;
import com.lili.exam.service.ExamService;
import com.lili.exam.service.ExamServiceImpl;
import com.lili.exam.util.BeanFactory;
import com.opensymphony.xwork2.ActionSupport;

public class ModifyInfoAction extends ActionSupport{
	private String name;
	private String xuehao;
	private String password;
	private String newpassword;
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getNewpassword() {
		return newpassword;
	}
	public void setNewpassword(String newpassword) {
		this.newpassword = newpassword;
	}
	
	public String execute(){
		Student stu = null;
		ExamService service = (ExamServiceImpl)BeanFactory.getBean("examService");
		try {
			stu = service.getStudentByXuehao(xuehao);
			String passwd = stu.getPassword();
			if(!passwd.equals(password)){
				ServletActionContext.getRequest().setAttribute("message","密码错误!");
				return INPUT;
			}
			stu.setPassword(newpassword);
			service.saveOrUpdateStudent(stu);
			ServletActionContext.getRequest().setAttribute("message","修改密码成功!");
		} catch (ExamException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return SUCCESS;
	}
	public String getXuehao() {
		return xuehao;
	}
	public void setXuehao(String xuehao) {
		this.xuehao = xuehao;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
}

⌨️ 快捷键说明

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