📄 findallaction.java
字号:
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.test.struts.action;
import java.io.IOException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.test.struts.domain.User;
import com.test.struts.service.UserPopedomService;
import com.test.struts.service.UserService;
/**
* MyEclipse Struts
* Creation date: 05-09-2009
*
* XDoclet definition:
* @struts.action path="/findAll" name="findAllForm" input="/form/findAll.jsp" scope="request" validate="true"
*/
public class FindAllAction extends Action {
/*
* Generated Methods
*/
private String usermethod;
private UserService userService;
private UserPopedomService userPopedomService;
public UserService getUserService() {
return userService;
}
public void setUserService(UserService userService) {
this.userService = userService;
}
public UserPopedomService getUserPopedomService() {
return userPopedomService;
}
public void setUserPopedomService(UserPopedomService userPopedomService) {
this.userPopedomService = userPopedomService;
}
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
usermethod=request.getParameter("usermethod");
System.out.println(mapping.getPath());
if(usermethod.equals("findAll")){
List<User> list=userService.findAllUsers();
request.setAttribute("users", list);
try {
request.getRequestDispatcher("/form/findAll.jsp").forward(
request, response);
} catch (ServletException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
if("edit".equals(usermethod)){
System.out.println("usermethod:"+usermethod);
request.setAttribute("user", userService.findUser(Integer.parseInt(request.getParameter("id"))));
try {
request.getRequestDispatcher("/form/edit.jsp").forward(
request, response);
} catch (ServletException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
if("editPassword".equals(usermethod)){
System.out.println("usermethod:"+usermethod);
request.setAttribute("user", userService.findUser(Integer.parseInt(request.getParameter("id"))));
try {
request.getRequestDispatcher("/form/editPassword.jsp").forward(
request, response);
} catch (ServletException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
if("delete".equals(usermethod)){
System.out.println("usermethod:"+usermethod);
request.setAttribute("user", userService.findUser(Integer.parseInt(request.getParameter("id"))));
try {
request.getRequestDispatcher("/form/delete.jsp").forward(
request, response);
} catch (ServletException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
return null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -