📄 appaction.java
字号:
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.sean.pet.controller.action;
import java.sql.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import com.sean.pet.controller.form.AppForm;
import com.sean.pet.hibernate.po.Appointment;
import com.sean.pet.model.service.AppointmentService;
import com.sean.pet.modelfactory.ModelFactory;
/**
* MyEclipse Struts Creation date: 08-08-2008
*
* XDoclet definition:
*
* @struts.action path="/app" name="appForm" parameter="method" scope="request"
* validate="true"
*/
public class AppAction extends DispatchAction {
/*
* Generated Methods
*/
/**
* Method execute
*
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
private AppointmentService appService;
public AppAction() {
super();
this.appService = (AppointmentService) ModelFactory
.getBean("com.sean.pet.model.service.impl.AppointmentServiceImpl");
}
public ActionForward toSave(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
// this.saveToken(request);
return mapping.findForward("appAdd");
}
public ActionForward save(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
// TODO Auto-generated method stub
AppForm appForm = (AppForm) form;
// if (this.isTokenValid(request)) {
// resetToken(request);
System.out.println("save------" + appForm.getPet().getId());
System.out.println("save------" + appForm.getTime());
Date atime = Date.valueOf(appForm.getAtime());
System.out.println("save------" + atime);
// java.text.DateFormat df = new
// java.text.SimpleDateFormat("yyyy-MM-dd");
appForm.setTime(atime);
System.out.println("savepetid------" + appForm.getPetid());
System.out.println("savepetname------"
+ appForm.getPet().getPetowner().getId());
System.out.println("savepetname------"
+ appForm.getPet().getPetowner().getName());
System.out.println("savepetname------"
+ appForm.getPet().getPetowner().getTel());
System.out.println("save++++++" + appForm.getPet().getId());
System.out.println("save++++++" + appForm.getPet().getType());
System.out.println("savedesc------" + appForm.getAtime());
this.appService.save(appForm.valueOfUsers());
return mapping.findForward("toShow");
// } else {
// saveToken(request);
// System.out.println("重复提交");
// return mapping.findForward("toShow");
// }
}
public ActionForward delete(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
String id = request.getParameter("id");
this.appService.delete(id);
return mapping.findForward("toShow");
}
@SuppressWarnings("unchecked")
public ActionForward showList(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
List<Appointment> list = this.appService.findAll();
// System.out.println("applist------" + list.get(1).getTime());
request.setAttribute("allApp", list);
return mapping.findForward("appList");
}
public ActionForward toUpdate(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
// EmpForm empForm = (EmpForm) form;// TODO Auto-generated method stub
String id = request.getParameter("id");
// System.out.println("toUpdate--"+id);
Appointment app = null;
// if(emp != null){
app = this.appService.findByID(id);
// System.out.println("toUpdate+++"+pet.getPetowner().getId());
// }
// this.saveToken(request);
request.setAttribute("app", app);
return mapping.findForward("appEdit");
}
public ActionForward update(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
// if (isTokenValid(request)) {
// resetToken(request);
AppForm appForm = (AppForm) form;
System.out.println("save------" + appForm.getPet().getId());
System.out.println("save------" + appForm.getTime());
Date atime = Date.valueOf(appForm.getAtime());
// java.text.DateFormat df = new
// java.text.SimpleDateFormat("yyyy-MM-dd");
appForm.setTime(atime);
System.out.println("savepetid------" + appForm.getPetid());
System.out.println("savepetname------"
+ appForm.getPet().getPetowner().getId());
System.out.println("savepetname------"
+ appForm.getPet().getPetowner().getName());
System.out.println("savepetname------"
+ appForm.getPet().getPetowner().getTel());
System.out.println("save++++++" + appForm.getPet().getId());
System.out.println("save++++++" + appForm.getPet().getType());
System.out.println("savedesc------" + appForm.getAtime());
this.appService.update(appForm.valueOfUsers());
return mapping.findForward("toShow");
// } else {
// saveToken(request);
// System.out.println("重复提交");
// return mapping.findForward("toShow");
// }
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -