













在Web.xml中
<!-- 需要拦截的JSP -->
<filter>
<filter-name>sessionFilter</filter-name>
<filter-class>sy.util.base.SessionFilter</filter-class>
<init-param>
<param-name>include</param-name>
<!-- 在securityJsp这个文件夹下面的所有JSP页面,都需要有session才能访问,可以配置多个,用英文半角逗号分割 -->
<param-value>securityJsp</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>sessionFilter</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>
sessionFilter监听的网址中如果包含Include里的部分,则需要session才能访问
效果:
<!-- 用户上下线监听器 -->
<listener>
<listener-class>sy.util.base.OnlineListener</listener-class>
</listener>
OnlineListener 会监听在线用户上线下线
效果:
在struts.xml中
<!-- session拦截器 -->
<interceptor name="sessionInterceptor" class="sy.interceptor.base.SessionInterceptor" />
<interceptor-stack name="sessionStack">
<interceptor-ref name="encodingStack"></interceptor-ref>
<interceptor-ref name="sessionInterceptor">
<!-- doNotNeedSessionAndSecurity_ 开头的和doNotNeedSession_ 开头的方法不拦截 -->
<param name="excludeMethods">doNotNeedSession_*,doNotNeedSessionAndSecurity_*</param>
</interceptor-ref>
</interceptor-stack>
sessionInterceptor拦截非jsp后缀的
效果:
<!-- 权限拦截器 -->
<interceptor name="securityInterceptor" class="sy.interceptor.base.SecurityInterceptor" />
<interceptor-stack name="securityStack">
<interceptor-ref name="sessionStack"></interceptor-ref>
<interceptor-ref name="securityInterceptor">
<!-- doNotNeedSessionAndSecurity_ 开头的和doNotNeedSecurity_ 开头的方法不拦截 -->
<param name="excludeMethods">doNotNeedSecurity_*,doNotNeedSessionAndSecurity_*</param>
</interceptor-ref>
</interceptor-stack>
</interceptors>
securityInterceptor检测权限
效果:
<global-results>
<!-- 没有session -->
<result name="noSession">/error/noSession.jsp</result>
<!-- 没有权限 -->
<result name="noSecurity">/error/noSecurity.jsp</result>
<!-- struts抛异常 -->
<result name="strutsException">/error/strutsException.jsp</result>
</global-results>
<global-exception-mappings>
<exception-mapping result="strutsException" exception="java.lang.Exception"></exception-mapping>
</global-exception-mappings>
Action结构:
其他Action通过继承BaseAction并传递相应Service来获得共有功能
包括统一命名的字段,以及基础的CUID,json处理等
Service结构:
其他Service通过继承BaseService来获得基础CUID
ServiceImpl结构:
BaseServiceImpl中注入了BaseDao
另外还有个InitServiceImpl,用来初始化
通过读取配置文件中的initDataBase.xml来写入数据库
SAX方式读取,并使用了XPath
页面部分,一个公共加载页,inc.jsp,包含公用功能及js库
登陆后的main页面是一个easyUI的layout
上面为账户相关
左边为导航菜单
中间为easyUI-tab,每个tab都是一个iframe
还有model部分:
对easyui需要的格式进行了对象封装
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。