Chinaunix首页 | 论坛 | 博客
  • 博客访问: 327675
  • 博文数量: 96
  • 博客积分: 2041
  • 博客等级: 大尉
  • 技术积分: 1080
  • 用 户 组: 普通用户
  • 注册时间: 2012-01-20 14:08
文章分类

全部博文(96)

文章存档

2015年(2)

2013年(1)

2012年(93)

分类: 系统运维

2012-01-22 15:19:05

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 }
   
  
 

阅读(452) | 评论(0) | 转发(0) |
0

上一篇:struts2模型驱动

下一篇:Preparable接口

给主人留下些什么吧!~~