⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 showuseraction.java

📁 这是《Struts网络编程实例》一书zhogn 的源代码部分
💻 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 + -