📄 addcategoryaction.java
字号:
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.david.struts.action;
import java.io.IOException;
import java.sql.Date;
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 com.david.bo.Category;
import com.david.bo.Userinfo;
import com.david.service.ICategoryService;
import com.david.struts.form.AddCategoryForm;
import com.david.validate.Validate;
/**
* MyEclipse Struts
* Creation date: 10-17-2007
*
* XDoclet definition:
* @struts.action path="/addCategory" name="addCategoryForm" input="/form/addCategory.jsp" scope="request" validate="true"
*/
public class AddCategoryAction extends FilterRequestAction {
/*
* Generated Methods
*
*
*/
private ICategoryService categoryService;
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
* @throws IOException
*/
public ActionForward doExecute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws IOException {
AddCategoryForm addCategoryForm = (AddCategoryForm) form;// TODO Auto-generated method stub
Category category=new Category();
category.setAddTime(new Date(System.currentTimeMillis()));
category.setCategoryIntro(addCategoryForm.getCategoryIntro());
category.setCategoryName(addCategoryForm.getCategoryName());
category.setUserinfo((Userinfo)request.getSession().getAttribute("USERINFO"));
//ICategoryService categoryService=(ICategoryService)this.getBean("categoryService");
if(categoryService.addCategory(category)){
return mapping.findForward("addCategoryOk");
}else{
response.getWriter().print("Error!<br/>Maybe you can't connect database!<br/>please check database connection!");
return null;
}
}
public void setCategoryService(ICategoryService categoryService) {
this.categoryService = categoryService;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -