package com.mstf.action;



import java.util.List;

import com.mstf.bean.Info;
import com.mstf.service.InfoService;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
@SuppressWarnings("serial")//----------处理黄线警告--

public class InfoAction extends ActionSupport implements ModelDriven<Info>{
	//----导入ActionSupport包,和ModelDriven包
	private Info info;
	private InfoService infoService;
	//---导入InfoService包,
	
	//-------------------写Struts中的视图-----
	public String list() throws Exception{
		List<Info> infolist=infoService.getAll();
		ActionContext.getContext().put("infolist", infolist);
		
		return "list";
		
	}
	//-----------增加两个请求,
	public String addUI() throws Exception{
		return "addUI";
		
	}
	
	public String add() throws Exception{
		infoService.save(info);
		return "tolist";
		
	}
	//-------更新两个请求---,
	public String updateUI() throws Exception{
		//---跳转到修改页面
		Info infos=infoService.getById(info.getId());
		ActionContext.getContext().getValueStack().push(infos);
		return "updateUI";
		
	}
	public String update() throws Exception{
		//---进行修改操作
		Info infos=infoService.getById(info.getId());
		infos.setName(info.getName());
		infos.setAge(info.getAge());
		infos.setAddress(info.getAddress());
		infoService.update(infos);
		return "tolist";
		
	}
	
	public String delete() throws Exception{
		infoService.delete(info.getId());
		return "tolist";
		
	}
	

	@Override
	public Info getModel() {
		// TODO Auto-generated method stub
		info =new Info();
		return info;
	}

	//------------为private InfoService infoService;提供getter和setter方法,
	public InfoService getInfoService() {
		return infoService;
	}

	public void setInfoService(InfoService infoService) {
		this.infoService = infoService;
	}
	
	

}
最近下载更多
张大大的账号  LV2 2022年4月26日
过过成功尺寸  LV7 2021年12月20日
yexiansheng  LV1 2021年11月6日
864152530  LV5 2021年6月5日
twotwo  LV8 2019年12月23日
Jack222  LV7 2019年11月14日
在云端i  LV9 2019年10月19日
拾光979  LV11 2019年9月9日
wanglian123  LV1 2019年7月8日
涛涛8888  LV6 2019年7月2日
最近浏览更多
yhe107  LV3 3月18日
flygrass  LV12 2023年12月7日
张三的MySQL 2023年5月5日
暂无贡献等级
张大大的账号  LV2 2022年4月26日
isfrand  LV4 2022年4月18日
wanglinddad  LV54 2022年4月13日
HUAJIHUAJI 2021年12月22日
暂无贡献等级
过过成功尺寸  LV7 2021年12月20日
lihuazhen  LV2 2021年12月17日
huaua7676  LV30 2021年11月16日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友