关于struts2拦截器的一问题!有代码.
struts.xml中拦截器配置
<include file="struts-default.xml"/>
<constant name="struts.devMode" value="true" />
<package name="struts2" extends="struts-default" namespace="/caifu">
<interceptors>
<interceptor name="auth" class="com.lil.test_ch10_03.interceptor.AuthenticationInterceptor" />
<interceptor-stack name="securityStack">
<interceptor-ref name="defaultStack" />
<interceptor-ref name="auth" />
</interceptor-stack>
</interceptors>
<global-results>
<result name="login">/caifu/login.jsp</result>
</global-results>
<action name="resource">
<result>/caifu/resource.jsp</result>
<interceptor-ref name="securityStack" />
</action>
<!-- 后台登录 -->
<action name="loginAction" class="loginAction">
<result name="success" type="redirect-action">userManageAction!list.action</result>
<result name="input">/caifu/login.jsp</result>
<result name="inter">/caifu/quanxian.jsp</result> //其它用户跳转到这个页面 </action>
<!-- 系统用户显示 -->
<action name="userManageAction" class="userManageAction">
<result name="list">/caifu/index.jsp</result>
<result name="view">/caifu/systemadminlist.jsp</result>
<result name="getbyid">/caifu/adminedit.jsp</result>
<result name="updatelist" type="redirect-action">/userManageAction!list.action</result>
<result name="dellist" type="redirect-action">/userManageAction!list.action</result>
<result name="save" type="redirect-action">/userManageAction!list.action</result>
<result name="inter">/caifu/quanxian.jsp</result>
</action>
Action部分代码
public String execute() throws Exception {
List adminList = loginservice.list(loginvo);
if ("yuhuan".equals(loginvo.getName())
&& "goview".equals(loginvo.getPsw())) {
ActionContext.getContext().getSession()
.put("userManage", loginvo.getName());
ActionContext.getContext().getSession().put("psw", loginvo.getPsw());
System.out.println("-------------");
return "success";
} else {
return "inter";
}
}
登录后jsp页:
<ul>
<li>
<a href="<s:url action="userManageAction!list.action" />">系统用户</a></li>
<p>
<li>
<a href="<s:url action="clientInfo!clientList.action" />">客户</a>
</li><p>
<li>
quanxian.jsp页面
<s:label>无权限访问! <input type="text" name="works" value="1"/> </s:label>
------解决方案-