我的路线文件夹中有ships.js
:
var express = require('express');
var router = express.Router();
/* GET Ships page. */
router.get('/ships', function(req, res, next) {
res.render('ships', { title: 'Express' });
});
module.exports = router;
我在app.js
:
var routes = require('./routes/index');
var users = require('./routes/users');
var ships = require('./routes/users');
和
app.use('/', routes);
app.use('/ships', ships);
app.use('/users', users);
但是,如果我导航到localhost:3000/ships
,我会收到以下消息:
以资源回复
很抱歉已阅读过这些文档,只是不要用快递来表达。
答案 0 :(得分:0)
您app
模块中有两个错误:
1. require
路由无效ships
:
var ships = require('./routes/users'); <--
// should be:
var ships = require('./routes/ships');
2. router
使用无效app.use
:
app.use('/ships', ships);
// should be:
app.use(ships); // and the same for others