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

全部博文(96)

文章存档

2015年(2)

2013年(1)

2012年(93)

分类: 系统运维

2012-01-25 00:09:02

login.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>



 
   


    username:

    password:

    age:

    date:

   
   

 

 

struts.xml


    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    ">

   
       
           
                     shengsiyuan
                    

           
       
       
       
           
           
       

       

        
       
            /usernameInvalid.jsp
            /passwordInvalid.jsp
            /error.jsp
       

       
           
           
       

       
            /result.jsp
            /login.jsp
       

       
           
            action2
            ${username}
            ${password}
            ${usernameAndPassword}
           
           
       
           
           
            
             execute,myExecute
        
    

            
       

      
           /tokenSuccess.jsp
           tokenFail.jsp
    
    
      

      
       /action2.jsp
      

       
            /result.jsp
       

       
            /output.jsp
       

       
            /output.jsp
       

       
            /registerResult.jsp
            /register.jsp
       

   

 

 

LoginInterceptor.java

package com.shengsiyuan.interceptor;

import java.util.Map;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import com.shengsiyuan.struts2.LoginAction;

public class LoginInterceptor extends AbstractInterceptor
{

    @Override
    @SuppressWarnings("unchecked")
    public String intercept(ActionInvocation invocation) throws Exception
    {
        if(LoginAction.class == invocation.getAction().getClass())
        {
            return invocation.invoke() ;
        }
        Map map = invocation.getInvocationContext().getSession() ;
        if(null == map.get("userInfo"))
        {
            return Action.LOGIN ;
        }
        return invocation.invoke() ;
    }

}

 

 

error.jsp

<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
 
 
    还没登录
 

阅读(1049) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~