lt;divgt;
lt;form action="list.action"gt;
lt;s:if test="%{p.page != 1}"gt;
lt;a href="https://www.04ip.com/post/list.action?p.page=1"gt;首页lt;/agt;
lt;/s:ifgt;
lt;s:elsegt;
lt;a style="color:#ccc;"gt;首页lt;/agt;
lt;/s:elsegt;
lt;s:if test="%{p.page != 1}"gt;
lt;a href="https://www.04ip.com/post/list.action?p.page=${p.page-1 }"gt;上一页lt;/agt;
lt;/s:ifgt;
lt;s:if test="%{p.page != p.totalPage}"gt;
lt;a href="https://www.04ip.com/post/list.action?p.page=${p.page+1 }"gt;下一页lt;/agt;
lt;/s:ifgt;
lt;s:if test="%{p.page != p.totalPage}"gt;
lt;a href="https://www.04ip.com/post/list.action?p.page=${p.totalPage }"gt;末页lt;/agt;
lt;/s:ifgt;
lt;s:elsegt;
lt;a style="color:#ccc;"gt;末页lt;/agt;
lt;/s:elsegt;
lt;spangt;第${p.page }页/共${p.totalPage }页lt;/spangt;
lt;spangt;跳lt;input id="page" name="p.page" style="width:30px;"gt;页lt;/spangt;
lt;input type="submit" value="https://www.04ip.com/post/go"gt;
lt;/formgt;
lt;/divgt;
lt;divgt;
lt;input type="button" value="https://www.04ip.com/post/添加用户" onclick="window.location='add.jsp'"/gt;
lt;/divgt;
lt;/bodygt;
lt;/htmlgt;
package com.action;
import java.util.ArrayList;
import java.util.List;
import com.dao.UserDao;
import com.dao.UserDaoImpl;
import com.opensymphony.xwork2.ActionSupport;
import com.pojo.User;
import com.util.Pagination;
public class UserAction extends ActionSupport{
private UserDao dao = new UserDaoImpl();
private Listlt;Usergt; users = new ArrayListlt;Usergt;();
private User user;
private int id;
private Pagination p = new Pagination();
public String list(){
System.out.println("======================list.action");
try {
System.out.println("list:"+p.getPage()+p.getPageSize());
dao.getMaxPage(p);
users = dao.list(p);
return "success";
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "failed";
}
public String add(){
System.out.println("======================add.action");
try {
dao.add(user);
return "success";
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "failed";
}
public String delete(){
System.out.println("======================delete.action");
try {
dao.delete(id);
return "success";
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "failed";
}
public String load(){
System.out.println("======================load.action");
try {
user = dao.findUserById(id);
return "success";
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "failed";
}
public String modify(){
System.out.println("======================modify.action");
try {
user.setId(id);//设置user的id为所要修改的id
dao.update(user);
return "success";
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "failed";
}
public Listlt;Usergt; getUsers() {
return users;
}
public void setUsers(Listlt;Usergt; users) {
this.users = users;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public Pagination getP() {
return p;
}
public void setP(Pagination p) {
this.p = p;
}
}
package com.util;
/**
推荐阅读
- css简单样式代码,css样式代码写在什么位置
- scratch中文版下载,scratch中文版下载30
- 手机app毕业设计用什么软件做,适合毕业设计的手机app
- pdf如何切换成PPT,pdf怎么变为ppt
- java代码居中 java代码怎么对齐
- 玩手游平板安卓推荐,玩手游平板电脑推荐
- 气压毕业设计的计算,气压毕业设计可以设计写什么
- 夏季工厂清仓直播文案,直播间清仓玩法
- 前端代码多还是java 前端比java简单吗