?? showuserlistaction.java
字號:
package org.ithinking.strutsExample.Action;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
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.ithinking.strutsExample.entity.Userinfo;
import org.ithinking.strutsExample.service.ServiceFactory;
import org.ithinking.strutsExample.service.UserInfoService;
import org.ithinking.strutsExample.util.SiteContance;
public class ShowUserListAction extends Action {
public ActionForward execute(ActionMapping actionMapping,
ActionForm actionForm,
HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse) {
//如果沒有登陸信息,則返回登陸頁面
if(httpServletRequest.getSession().getAttribute(SiteContance.CURRENT_USER)==null)
{
return actionMapping.findForward("login");
}
else
{
try
{
UserInfoService userInfoservice=ServiceFactory.getUserinfService();
List userInfoList=userInfoservice.getUserInfoList();
//添加userlist屬性,同jsp頁面的中的名字相一致
httpServletRequest.setAttribute("userlist",userInfoList);
return actionMapping.findForward("success");
}
catch(Exception ex)
{
ex.printStackTrace();
ActionErrors errors = new ActionErrors();
errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(
"global.errors.general"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -