日期:2014-05-19 浏览次数:20770 次
http://localhost:8080/OrderS/trainInfo/delete.action?id=5
<package name="SSH" namespace="/ssh" extends="struts-default">
<interceptors>
<interceptor name="login" class="com.xing.util.LoginInterceptor"></interceptor>
<interceptor-stack name="myLogin">
<interceptor-ref name="login"></interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="myLogin"></default-interceptor-ref>
<global-results>
<result name="login" type="redirect">/admin/login.jsp</result>
</global-results>
<!--删除 信息 -->
<action name="deleteAction" class="com.xing.action.InstrumentAction"
method="delete">
<result name="success">/admin/instrument/success.jsp</result>
</action>
<!-- 超级管理员 删除 -->
<action name="deleteAction1" class="com.xing.action.NoticeAction"
method="delete">
<result name="success">/admin/notice/success.jsp</result>
</action>
<!-- 普通管理员 删除 -->
<action name="deleteAction2" class="com.xing.action.NoticeAction"
method="delete">
<result name="success">/manager/notice/success.jsp</result>
</action>
</package>
<interceptors>
<interceptor name="login" class="com.xing.util.LoginInterceptor"></interceptor>
<interceptor-stack name="myLogin">
<interceptor-ref name="login"></interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="myLogin"></default-interceptor-ref>
<global-results>
<result name="login" type="redirect">/admin/login.jsp</result>
</global-results>
public class LoginInterceptor extends AbstractInterceptor {
/**
*
*/
private static final long serialVersionUID = 1L;
@SuppressWarnings("unchecked")
@Override
public String intercept(ActionInvocation invocation) throws Exception {
String name = invocation.getInvocationContext().getName();
if(name.equals("login"))
{
//如果用户想登陆,则使之通过
return invocation.invoke();
}
else
{
ActionContext ac = invocation.getInvocationContext();
Map session = (Map)ac.get(ServletActionContext.SESSION);
if(session==null)
{
//如果session为空,则让用户登陆
return "login";
}
else
{
String adminname = (String)session.get("adminname");
if(