错误:“node_modules / express / lib / router / index.js:458 Router.use()需要一个中间件函数,但在Function.use中有一个Object”
代码:
const router = require('express').Router();
const Students = require('../models/students.js');
router.get('/',
Students.findAll, (req, res) => {
res.render('students/index', {studentsData: res.locals.allStudentsData})
});
router.get('/:id', Students.findById, (req, res) => {
res.render('students/show', res.locals.showStudent)
});
module.exports = router;
控制器/ students.js: 这是第一个链接到index.js
的文件const router = require('express').Router();
const Houses = require('../models/houses.js');
router.get('/',
Houses.findAll, (req, res) => {
res.render('houses/index', {housesData: res.locals.allHousesData})
});
router.get('/:id', Houses.findById, (req, res) => {
res.render('houses/show', res.locals.showHouse)
});
module.exports = router;
控制器/ houses.js: 这是链接到index.js
的第二个文件@Deployment
public static JavaArchive createDeployment() {
return ShrinkWrap.create(JavaArchive.class)
.addClasses(MyXBean.class, DefaultMyXBean.class, TermsOfUse.class)
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
}