Struts2中拦截器
Posted 呦,你是个老母猪呦!
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Struts2中拦截器相关的知识,希望对你有一定的参考价值。
- 创建拦截器
package com.zhangpn.Intercepor; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionInvocation; import com.opensymphony.xwork2.interceptor.Interceptor; public class PermissionIntercepor implements Interceptor{ @Override public void destroy() { // TODO Auto-generated method stub } @Override public void init() { // TODO Auto-generated method stub } @Override public String intercept(ActionInvocation arg0) throws Exception { // TODO Auto-generated method stub return null; } }
intercept方法为拦截过程。
- 配置文件:
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" "http://struts.apache.org/dtds/struts-2.3.dtd"> <struts> <constant name="struts.multipart.saveDir" value="/tmp"/> <package name="default" namespace="/" extends="struts-default"> <interceptors> <interceptor name="PERMIT" class="com.zhangpn.Intercepor.PermissionIntercepor"></interceptor> </interceptors> <action name="index" class="com.zhangpn.struts2.Uploadfile"> <interceptor-ref name="PERMIT"/> <result name="success">welcome.jsp</result> <result name="error">error.jsp</result> </action> </package> </struts>
以上是关于Struts2中拦截器的主要内容,如果未能解决你的问题,请参考以下文章