首页>代码>SSH框架开发简单的学生信息后台管理系统>/stuinfoSys/src/com/lk/action/StudentAction.java
package com.lk.action;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Scope;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Component;

import com.lk.model.Student;
import com.lk.model.User;
import com.lk.service.StudentManager;
import com.lk.service.UserManager;
import com.lk.vo.Info;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

@Component("student")
@Scope("prototype")
public class StudentAction extends ActionSupport implements ModelDriven{
	
	private Info info = new Info();
	
	private StudentManager studentManager;
	
	private List<Student> students;

	public List<Student> getStudents() {
		return students;
	}
	public void setStudents(List<Student> students) {
		this.students = students;
	}
	public StudentManager getStudentManager() {
		return studentManager;
	}
	@Resource(name="studentManager")
	public void setStudentManager(StudentManager studentManager) {
		this.studentManager = studentManager;
	}
	
	
	public Info getInfo() {
		return info;
	}
	public void setInfo(Info info) {
		this.info = info;
	}

	/**
	 * 增加学生信息
	 * @return
	 * @throws Exception
	 */
	public String add() throws Exception{
		Student stu = new Student();
		stu.setId(info.getId());
		stu.setSid(info.getSid());
		stu.setName(info.getName());
		stu.setCollege(info.getCollege());
		stu.setProfession(info.getProfession());
		studentManager.add(stu);
		return "success";
	}
	
	/**
	 * 查询学生信息
	 * @return
	 * @throws Exception
	 */
	public String list() throws Exception{
		this.students = this.studentManager.getStudents();
		return "list";
	}
	/**
	 * 获取需要删除学生信息的学号
	 * @return
	 * @throws Exception
	 */
	public String numberlistfordelete() throws Exception{
		this.students = this.studentManager.getStudents();
		return "numberlistfordelete";
	}
	/**
	 * 获取需要修改学生信息的学号
	 * @return
	 * @throws Exception
	 */
	public String numberlistformodify() throws Exception{
		this.students = this.studentManager.getStudents();
		return "numberlistformodify";
	}
	
	/**
	 * 删除学生信息
	 * @return
	 * @throws Exception
	 */
	public String delete() throws Exception{
		studentManager.delete(Integer.parseInt(info.getSelect()));
		return "delete";
	}
	
	/**
	 * 更新学生信息
	 * @return
	 * @throws Exception
	 */
	public String modify() throws Exception{
		Student stu = new  Student();
		stu.setCollege(info.getCollege());
		stu.setName(info.getName());
		stu.setProfession(info.getProfession());
		stu.setSid(info.getSid());
		System.out.println(stu.getCollege()+ " " +stu.getProfession() + " "+ stu.getName()+" "+ stu.getSid());
		studentManager.update(stu.getCollege(), stu.getProfession(), stu.getName(), stu.getSid());
		return "modify";
	}
	
	public Object getModel() {
		// TODO Auto-generated method stub
		return info;
	}
	
	
}
最近下载更多
zhangbo2020  LV6 2023年11月22日
li951753  LV2 2023年6月18日
3516569014  LV5 2023年5月7日
ppppddww  LV2 2023年4月26日
and123456  LV11 2022年2月19日
jay1992  LV14 2021年12月29日
原来是黎笙呀  LV1 2021年12月21日
1798139161  LV4 2021年12月5日
lsglsg9  LV23 2021年11月28日
178174qasw  LV10 2021年8月19日
最近浏览更多
1516299986  LV9 4月16日
ma406805131  LV19 2024年12月27日
571818771  LV3 2024年12月16日
abdkfksdkf  LV16 2024年9月18日
卢旯旯  LV4 2024年6月10日
hai341228  LV1 2024年5月24日
LiBaQi  LV2 2023年12月22日
颜菜菜  LV2 2023年12月21日
WBelong  LV8 2023年12月11日
zhangbo2020  LV6 2023年11月22日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友