LoginAction.java
public String execute() throws Exception //有业务逻辑的验证放在这里,而不放在validate里
{
//jsp页面
HttpServletRequest request = ServletActionContext.getRequest() ;
HttpSession session = request.getSession() ;
session.setAttribute("hello", "helloworld") ;
//后台显示
ActionContext actionContext =ActionContext.getContext();
Map map = actionContext.getSession() ;
Object object = map.get("hello") ;
System.out.println(object);
if(this.loginService.isLogin(username, password))
{
return SUCCESS ;
}
return INPUT ;
}
result.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
username: ${requestScope.username }
password: ${requestScope.password }
age: ${requestScope.age }
date: ${requestScope.date }
session:${sessionScope.hello }
阅读(482) | 评论(0) | 转发(0) |