package com.kechengsheji.action; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionSupport; import com.kechengsheji.dao.AdminDAO; import com.kechengsheji.domain.Admin; public class LoginAction extends ActionSupport { private Admin admin; public Admin getAdmin() { return admin; } public void setAdmin(Admin admin) { this.admin = admin; } /*直接跳转到登陆界面*/ public String view() { return "login_view"; } /* 验证用户登录 */ public String CheckLogin() { AdminDAO adminDAO = new AdminDAO(); ActionContext ctx = ActionContext.getContext(); if (!adminDAO.CheckLogin(admin)) { ctx.put("error", java.net.URLEncoder.encode(adminDAO.getErrMessage())); return "error"; } ctx.getSession().put("username", admin.getUsername()); return "main_view"; /* * ActionContext ctx = ActionContext.getContext(); * ctx.getApplication().put("app", "应用范围");//往ServletContext里放入app * ctx.getSession().put("ses", "session范围");//往session里放入ses ctx.put("req", * "request范围");//往request里放入req ctx.put("names", Arrays.asList("老张", "老黎", * "老方")); HttpServletRequest request = ServletActionContext.getRequest(); * ServletContext servletContext = ServletActionContext.getServletContext(); * request.setAttribute("req", "请求范围属性"); * request.getSession().setAttribute("ses", "会话范围属性"); * servletContext.setAttribute("app", "应用范围属性"); // HttpServletResponse * response = ServletActionContext.getResponse(); */ } }
最近下载更多
and123456 LV11
2022年3月16日
644800782 LV4
2022年3月1日
刘可心 LV2
2021年3月20日
2215593477 LV9
2021年1月11日
liangge2115 LV27
2020年7月15日
双方各何必呢 LV13
2020年7月2日
EternalIy LV4
2020年6月17日
大杰打劫 LV8
2020年3月24日
ljlssb LV1
2019年12月16日
yawy007 LV4
2019年12月6日
最近浏览更多
哈哈ha zhh LV2
2023年11月7日
haoghuang
2023年1月3日
暂无贡献等级
3473084268 LV7
2022年12月11日
欧神1327
2022年12月11日
暂无贡献等级
Yier123 LV8
2022年9月30日
北末qwert LV2
2022年5月18日
微信网友_5961314929217536
2022年5月17日
暂无贡献等级
sunflower3
2022年5月13日
暂无贡献等级
xcwDeng0001 LV5
2022年3月13日
644800782 LV4
2022年3月1日