app.js中:
//-----------拦截器的实现-------------------------------------
var openPage = ['/','/users/regist','/users/login','/users/logout'];
app.use(function(req, res, next) {
var url = req.originalUrl;
if(openPage.indexOf(url)>-1){
next();
}else{
if(req.session.loginbean){
next();
}else{
res.redirect('/');
}
}
});