我正在使用expressjs,yeoman和angular。 Yeoman已被用於設置我的客戶端腳手架所以結構:快速錯誤500錯誤:查找視圖失敗「/ app/views/admin/users」
root folder app --> styles --> views -->admin login.html --> scripts routes node_modules server.js
我的server.js位於根級別。我正在使用angularjs渲染,但已使用服務器端的驗證來檢查用戶。
當它使用angularjs路由它在第一次加載罰款。如果我再刷新與網址的瀏覽器,它會返回錯誤:
快遞 500錯誤:無法查找視圖「/應用/視圖/管理/用戶」 在Function.app.render(/用戶/ TEJ /項目/ ecokidsproject/node_modules/express/lib/application.js:493:17) at ServerResponse.res.render(/Users/tej/Projects/ecokidsproject/node_modules/express/lib/response.js:798:7) at /Users/tej/Projects/ecokidsproject/server.js:148:9 at callbacks(/Users/tej/Projects/ecokidsproject/node_modules/express/lib/router/index.js:164:37) at param( /Users/tej/Projects/ecokidsproject/node_modules/express/lib/router/index.js:138:11) at pass(/ Users/tej/Projects/ecokidsproject/node_modules/expr eS/lib/router/index.js:145:5) at Router._dispatch(/Users/tej/Projects/ecokidsproject/node_modules/express/lib/router/index.js:173:5) at Object.router (/Users/tej/Projects/ecokidsproject/node_modules/express/lib/router/index.js:33:10) at Context.next(/ Users/tej/Projects/ecokidsproject/node_modules/express/node_modules/connect/lib /proto.js:193:15) 在Context.actions.pass(/Users/tej/Projects/ecokidsproject/node_modules/passport/lib/passport/context/http/actions.js:77:8)
配置是:
app.configure(function(){
app.set('port', process.env.PORT || 8500);
app.set('view engine', 'jade');
app.use(express.static(path.join(__dirname, '../app')));
app.use(express.static(path.join(__dirname, '/app/views')));
app.use(express.static(path.join(__dirname, '/app/views/admin')));
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.json());
app.use(express.urlencoded());
// app setup for authentication
app.use(express.bodyParser());
app.use(express.cookieParser());
app.use(express.session({ secret: 'ecoSecret' }));
app.use(express.methodOverride());
// Initialize Passport! Also use passport.session() middleware, to support
// persistent login sessions (recommended).
//app.use(flash());
app.use(passport.initialize());
app.use(passport.session());
app.use(app.router);
});
app.get('/admin', function(req, res){
console.log('get admin' + __dirname + '/app/views/admin/login.html');
res.render('/app/views/admin/users');
});
請在您的應用模塊中發佈您的路由提供商配置。 – michael
我的意思是角度js部分。有沒有什麼配置html5模式? – michael
是的,它使用locationprovider將htmlmode5設置爲true – tjhack