package com.bysj.action; import javax.annotation.Resource; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Controller; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionSupport; import com.bysj.dao.AdminDAO; import com.bysj.domain.Admin; @Controller @Scope("prototype") public class LoginAction extends ActionSupport { @Resource AdminDAO adminDAO; 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() { 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(); */ } }
最近下载更多
2716804680 LV8
2023年12月6日
ziv5466123 LV7
2023年6月26日
stonerose66 LV1
2023年6月23日
北方菜 LV11
2023年4月16日
2017143155 LV12
2022年11月14日
gch666 LV6
2022年6月8日
hebe灬 LV5
2022年5月21日
isfrand LV4
2022年4月19日
丁春秋 LV2
2022年3月15日
Lin一点 LV4
2021年12月16日
最近浏览更多
pi-nang LV2
3月11日
duoduo1234 LV2
1月15日
吴霞霞
2023年12月28日
暂无贡献等级
WBelong LV7
2023年12月27日
ysugxx LV9
2023年12月10日
2716804680 LV8
2023年12月6日
冀小鹏
2023年11月29日
暂无贡献等级
uio123 LV2
2023年11月4日
lyq6666666 LV5
2023年10月25日
iddlsdls LV1
2023年10月20日