配置等都没有问题 因为受限目录确实得到了保护 但是,问题时,无法访问的时候我设计的是转向另外一叶,但是现在情况时一片空白,就是阻止访问之后没有动作了 请问原因
codes r here:
package com.jspdev;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
public class SignonFilter implements Filter{
final private String LOGIN_PAGE= "http://www.sina.com.cn";
protected FilterConfig filterConfig;
/* (non-Javadoc)
* @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
*/
public void init(FilterConfig config) throws ServletException {
// TODO Auto-generated method stub
this.filterConfig = config;
}
/* (non-Javadoc)
* @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)
*/
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
// TODO Auto-generated method stub
HttpServletRequest hreq = (HttpServletRequest)req;
HttpServletResponse hres = (HttpServletResponse)res;
String isLogin = "";
HttpSession session = hreq.getSession();
try{
isLogin = session.getAttribute("isLogin").toString();
if(isLogin.equals("ture"))
{
System.out.println("access valid");
chain.doFilter(req,res);
}
else{
hres.sendRedirect(LOGIN_PAGE); //就是此处转向的
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
/* (non-Javadoc)
* @see javax.servlet.Filter#destroy()
*/
public void destroy() {
// TODO Auto-generated method stub
this.filterConfig = null;
}
public void setFilterConfig(final FilterConfig filterConfig)
{
this.filterConfig = filterConfig;
}