搜 索
快速找货
热门:
通信产品
照明
精细化学品
橡塑
纸业
电子元件
建筑建材
仪器仪表
化工
机械
首 页
采购市场
企业查询
营销建站
营销推广
行业资讯
发布信息
过滤器的问题
悬赏分:20
|
我要过滤所有页面除了登陆页面该做过滤所有/*,过滤登陆页写谢谢
知识库标签:
过滤器
|
列兵
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.io.IOException;
/**
* 用于检测用户否登陆过滤器未登录则重定向指登录页面
* <p>
* 配置参数
* <p>
* checkSessionKey 需检查 Session 保存关键字<br/> redirectURL
* 用户未登录则重定向指定页面URL包括 ContextPath<br/> notCheckURLList
* 做检查URL列表分号分开并且 URL 包括 ContextPath<br/>
*/
public class LoginFilter implements Filter {
private String redirectURL = null;
private List notCheckURLList = null;
private String sessionKey = null;
public void doFilter(ServletRequest servletRequest,
ServletResponse servletResponse, FilterChain filterChain)
throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) servletRequest;
HttpServletResponse response = (HttpServletResponse) servletResponse;
HttpSession session = request.getSession();
if (sessionKey == null) {
filterChain.doFilter(request, response);
return;
}
if ((!checkRequestURIIntNotFilterList(request))
&& session.getAttribute(sessionKey) == null) {
response.sendRedirect(request.getContextPath() + redirectURL);
return;
}
filterChain.doFilter(servletRequest, servletResponse);
}
public void destroy() {
notCheckURLList.clear();
}
private boolean checkRequestURIIntNotFilterList(HttpServletRequest request) {
String uri = request.getServletPath()
+ (request.getPathInfo() == null ? "" : request.getPathInfo());
return notCheckURLList.contains(uri);
}
public void init(FilterConfig filterConfig) throws ServletException {
redirectURL=....
sessionKey=.....
notCheckURLList=new ArrayList();
notCheckURLList.add("登陆页面");
notCheckURLList.add("/login.jsp");
notCheckURLList.add("登陆控制器");
}
}
用修改XML文件 XML直接完全过滤
使用过滤器 初始化时候定义 过滤页面和控制器
除了登陆页面还需要过滤 登陆控制器否则...
为最佳答案评分?
好
100% (1)
不好
0% (0)
(目前有 1 个人评价)
其 他 回 答
共3条
1楼
哦样用session检查session空时侯显示样了用session登陆给session赋值
知识库标签:
|
列兵
2楼
只有在过滤器时处理了.如果是登击页面就让它通过.
知识库标签:
过滤器
|
列兵
我来回答这个问题
立即登陆回答获取会员积分,提高用户级别
提交回答
热门标签
鸡肉
排水系统
抽油烟机
夹子
台灯
手机保护膜
洗手液
滤网
榨汁机
刹车灯
电话卡
位移传感器
增压泵
化学试剂
灭蚊灯
资格考试培训
手机配件
淀粉
家庭影院
食品添加剂
一周热点问题
1
y型过滤器和t型过滤器的区别
2
全自动过滤器工作原理是什么?
3
foxmail过滤器
4
如何选择精密过滤器?
5
cad对象选择过滤器有什么功能?
6
家庭用自来水过滤器的型号和价格?
7
过滤器的问题
7
业务做信报箱的上市公司有哪些
8
中间冷却器作用
9
色浆调色多久能学会
10
眼镜布是干什么用的??
11
跪求卫浴五金配件什么牌子的好啊
12
谁能说说小型电镀设备和技术?
过滤器相关企业
1
固安县长青过滤器材厂
2
银华过滤器材厂
3
安平县萁运过滤器材有限公司
4
固安隆达过滤器材有限公司
5
固安县中唐过滤器材厂
6
新乡市华豫过滤器有限公司
7
廊坊先科高效精密过滤器材厂
8
翔宇机械过滤器材厂
友情链接:
网站简介
-
本站声明
-
服务协议
-
信息投诉/删除/联系本站
-
京ICP备17049264号-1
Copyright ©
商名网
All Rights Reserved.