struts-action-trace.xml
<package name="tracePackage" namespace="/trace" extends="exceptionPackage"> <interceptors> <interceptor name="traceAuthInterceptor" class="com.fusionability.web.interceptor.TraceAuthInterceptor"></interceptor> <interceptor-stack name="traceAuthInterceptorStack"> <interceptor-ref name="defaultStack"></interceptor-ref> <interceptor-ref name="traceAuthInterceptor"></interceptor-ref> </interceptor-stack> </interceptors> <default-interceptor-ref name="traceAuthInterceptorStack"></default-interceptor-ref> <action name="showAppList" class="wKJSAppAction" method="showAppList"> <result name="success">/application/application_list.jsp</result> </action> </package>
package com.fusionability.web.interceptor; import org.apache.log4j.Logger; import org.apache.struts2.ServletActionContext; import com.fusionability.user.service.UserService; import com.fusionability.web.bean.User; import com.fusionability.web.bean.UserAppRelation; import com.fusionability.web.utils.Constants; import com.opensymphony.xwork2.Action; import com.opensymphony.xwork2.ActionInvocation; import com.opensymphony.xwork2.interceptor.AbstractInterceptor; /** * @author baoyou E-mail:curiousby@163.com * @version 2015年12月23日 下午2:47:10 * * desc: ... */ @SuppressWarnings("serial") public class TraceAuthInterceptor extends AbstractInterceptor { private static Logger log = Logger.getLogger(TraceAuthInterceptor.class); private UserService userService; @Override public String intercept(ActionInvocation invocation) throws Exception { User user = (User)ServletActionContext.getRequest().getSession().getAttribute(Constants.SESSION_USER); if (user == null) { return Action.LOGIN; }else{ if( !"/FusionAbility/trace/showAppList.action".equals(ServletActionContext.getRequest().getRequestURI())){ try { String appid = ServletActionContext.getRequest().getParameter("appid"); UserAppRelation userAppRelation = userService.getUserAppRelation(user.getUserid(), appid); if (userAppRelation != null) { return invocation.invoke(); } return "error"; } catch (Exception e) { //e.printStackTrace(); return "error"; } } return invocation.invoke(); } } public UserService getUserService() { return userService; } public void setUserService(UserService userService) { this.userService = userService; } }
捐助开发者
在兴趣的驱动下,写一个免费
的东西,有欣喜,也还有汗水,希望你喜欢我的作品,同时也能支持一下。 当然,有钱捧个钱场(右上角的爱心标志,支持支付宝和PayPal捐助),没钱捧个人场,谢谢各位。
谢谢您的赞助,我会做的更好!