package ssh.action;

import java.util.LinkedHashMap;
import javax.annotation.Resource;
import ssh.utils.QueryResult;
import ssh.utils.PageView;
import org.springframework.stereotype.Component;
import ssh.base.BaseAction;
import ssh.model.User;
import ssh.service.UserService;

//@Component("ua")
//@Scope("prototype")
public class UserAction extends BaseAction {
	private User user;
	private UserService userService;
	
	/**
	 * 这里必须要构造新对象,不然刚打开没有currentPage参数传递过来,如果不新建也行,第一次打开必须传递currentPage参数过来
	 */
	private PageView<User> pageView=new PageView<User>();	
	
	public PageView<User> getPageView() {
		return pageView;
	}

	public void setPageView(PageView<User> pageView) {
		this.pageView = pageView;
	}
	
	public UserService getUserService() {
		return userService;
	}

	//@Resource
	public void setUserService(UserService userService) {
		this.userService = userService;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@Override
	public String execute() throws Exception {
		int maxresult=5;											//设置每次显示条数
		int firstindex=(pageView.getCurrentPage()-1)*maxresult;		//定义分页开始索引
		LinkedHashMap<String, String> orderby = new LinkedHashMap<String, String>();	//定义排序
		orderby.put("id", "asc");
		
		QueryResult<User> qr=userService.getScrollData(firstindex,maxresult, "o.id>?", new Object[]{3}, orderby);
		pageView.setQueryResult(maxresult,qr);	//把查询结果和每页显示数传递给pageView
		request.put("pageView", pageView);
		return "index";
		
//		System.out.println("当前页"+pageView.getCurrentPage());
//		System.out.println("总页数"+pageView.getTotalPage());
//		System.out.println("总条数"+pageView.getTotalRecord());
//		System.out.println("startindex:"+pageView.getStartIndex());
//		System.out.println("endindex1:"+pageView.getEndIndex());
//		System.out.println("firstIndex:"+firstindex);
//		System.out.println("maxResult:"+pageView.getMaxResult());
//		System.out.println("currentPage:"+pageView.getCurrentPage());
		
	}
	
	public String save() throws Exception {
		userService.save(user);
		return "save";
	}
}
最近下载更多
PaymentCodeSystem  LV11 2022年9月9日
panyu329  LV1 2021年6月3日
and123456  LV11 2021年4月20日
雨后江岸天破晓  LV1 2020年6月23日
tumuwang  LV1 2019年12月4日
sixiongbin  LV8 2019年11月28日
r31506144  LV1 2019年5月20日
xiex909  LV27 2019年2月17日
意必固我  LV1 2019年1月16日
稀饭囡  LV9 2018年7月11日
最近浏览更多
PaymentCodeSystem  LV11 2022年9月9日
好的好的  LV8 2021年8月19日
.空运绵熊.  LV1 2021年6月5日
panyu329  LV1 2021年6月3日
jibamao  LV2 2021年4月27日
and123456  LV11 2021年4月20日
小星七的  LV12 2021年3月16日
0592lyj  LV9 2021年3月11日
mocker  LV6 2021年1月27日
ck10086  LV1 2021年1月11日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友