關於Session過期,我在web.xml中填寫了filter項目,但由於自己寫的filter類不能獲取到FacesContext或Session對象,不知道該怎樣在代碼中判斷session是否過期,也不知道什麽代碼能實現葉面的跳轉。望大家指點。謝謝!
解决方案 »
- java.sql.SQLException: The url cannot be null 寻求帮助
- 古老jar包的问题,struts-core-2.1.6中文乱码问题
- <input type="file" >问题
- 请教高手一个小问题,拜托了
- 值传递和显示
- 哪里有JSP的一些类的函数的帮助文件 ,类似于MSDN那中东西?
- 这个路径的设置很奇怪,是不是错了?
- 在 servlet 中 象这样的值 \u9648 \u952e\u56fd 可以直接转成繁体中文,但在JSP中就不行,直接输出\u9648 \u952e\u56fd ,不知怎么转?在
- 求一个JDK1.5编译的Spring2.5的Jar包
- 为什么这两句只能执行其一,是因为一个前端一个后端。
- 现在在学习jsp,想用mvc框架实现jsp页面的分页查找!师兄师姐们帮帮我!万分感谢!
- 求教这段代码的为什么提交不了表单啊
private String loginPage;
protected TUser _user; public void init(FilterConfig config) throws ServletException {
this.filterConfig = config;
loginPage = config.getInitParameter("loginPage");
if (loginPage == null) {
throw new ServletException("loginPage init param missing");
}
}
public void doFilter(final ServletRequest req, final ServletResponse
res, FilterChain chain) throws IOException,
ServletException {
HttpServletRequest hreq = (HttpServletRequest) req;
HttpServletResponse hres = (HttpServletResponse) res;
String url = hreq.getRequestURI()+"?"+hreq.getQueryString();
UserInfoDAO userInfoDAO = new UserInfoDAO();
_user = (TUser)hreq.getSession().getAttribute("_USER");
// String isLog = (String) hreq.getSession().getAttribute("validsession");
// if ( (isLog != null) && ( (isLog.equals("true")) || (isLog == "true"))) { //检查是否登录
if (_user!=null){
TUserinfo userInfo=userInfoDAO.findUserInfo(_user,"1");
chain.doFilter(req, res);
return;
}
else
hres.sendRedirect(loginPage);
}
public void destroy() {
this.filterConfig = null;
} public void setFilterConfig(final FilterConfig filterConfig) {
this.filterConfig = filterConfig;
} }