因为系统中的页面几乎都需要当前有用户登录才能有效访问
用个简单的Filter就能实现了,拦截所有请求。
package filter;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
public class OnlineFilter extends HttpServlet implements Filter
{
private static final long serialVersionUID = 1L;
public void init(FilterConfig filterConfig) throws ServletException
{
}
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
{
RequestDispatcher dispatcher = request.getRequestDispatcher("KK_BlacklistVehicle_UserLogin.jsp");
web.xml
<filter>
<filter-name>onlineFilter</filter-name>
<filter-class>filter.OnlineFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>onlineFilter</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>