📄 lendbook.java
字号:
package action;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import org.apache.struts2.ServletActionContext;
import com.bean.Tbook;
import com.bean.Tuser;
import com.dao.BookDAO;
import com.dao.UserDAO;
import com.opensymphony.xwork2.ActionSupport;
/**
*
* 进入借书页面数据准备action
*
*/
public class Lendbook extends ActionSupport {
private int bookid;
private Tuser tuser;
private Tbook tbook;
@Override
public String execute() throws Exception {
// TODO Auto-generated method stub
int userid = Integer.parseInt(ServletActionContext.getRequest().getSession().getAttribute("userid").toString());
tuser = new UserDAO().getUser(userid);
tbook = new BookDAO().getBook(bookid);
return SUCCESS;
}
public int getBookid() {
return bookid;
}
public void setBookid(int bookid) {
this.bookid = bookid;
}
public Tuser getTuser() {
return tuser;
}
public void setTuser(Tuser tuser) {
this.tuser = tuser;
}
public Tbook getTbook() {
return tbook;
}
public void setTbook(Tbook tbook) {
this.tbook = tbook;
}
/**
*
* 起始时间
*/
public String getStartDate() {
return new SimpleDateFormat("yyyy-MM-dd").format(new Date());
}
/**
*
* 终结时间
*/
public String getEndDate() {
int year = Calendar.getInstance().get(Calendar.YEAR) + 1;
int month = Calendar.getInstance().get(Calendar.MONTH) + 1;
int day = Calendar.getInstance().get(Calendar.DAY_OF_MONTH);
String endDate;
if (month < 10) {
endDate = year + "-0" + month + "-" + day;
}else {
endDate = year + "-" + month + "-" + day;
}
return endDate;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -