?? showuseraction.java
字號:
package org.ithinking.strutsExample.Action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
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 org.ithinking.strutsExample.entity.Userinfo;
import org.ithinking.strutsExample.service.ServiceFactory;
import org.ithinking.strutsExample.service.UserInfoService;
import org.ithinking.strutsExample.serviceImpl.UserInfoUtil;
import org.ithinking.utils.IntegerUtil;
public class ShowUserAction extends DispatchAction {
//顯示新增用戶信息的頁面
public ActionForward newuser(ActionMapping actionMapping,
ActionForm actionForm, HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse) {
return actionMapping.findForward("newuser");
}
//顯示修改用戶信息的頁面
public ActionForward modify(ActionMapping actionMapping,
ActionForm actionForm, HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse) {
//如果用戶id不合法,則顯示錯誤信息
if(httpServletRequest.getParameter("id")==null||(!IntegerUtil.isInteger((String)httpServletRequest.getParameter("id"))))
{
ActionErrors errors = new ActionErrors();
errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(
"global.findusererror"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("listuser");
}
UserInfoService userInfoservice=ServiceFactory.getUserinfService();
Userinfo userInfo=userInfoservice.getUserInfoById(Integer.valueOf((String)httpServletRequest.getParameter("id")));
//用來修改的用戶信息,同處理修改請求的action對應的actionform名稱保持一致
httpServletRequest.setAttribute("UserInfoActionForm",UserInfoUtil.getFormFromUserInfo(userInfo));
return actionMapping.findForward("modifyUser");
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -