分类: 系统运维
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+"/";
%>
struts.xml
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
">
shengsiyuan
action2
${username}
${password}
${usernameAndPassword}
execute,myExecute
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"%>