var express = require("express"); var ejs = require('ejs'); var path = require("path"); var app = express(); app.set('view engine', 'ejs'); app.engine('html', ejs.__express); app.use(express.static(path.join(__dirname,'/styles'))); app.get("/",function(req,res){ res.render("index",{title:"首页"}); }); app.get("/reg",function(req,res){ console.log(req.url) res.render("reg",{title : "用户注册"}); }); app.use(function(req,res){ res.end("404 error!"); }); app.listen(8080,function(){ console.log("the sever has been started"); })
http://127.0.0.1:8080/styles/bootstrap.min.css 报错:404 error!
但是目录的路径是对的啊。。
http://127.0.0.1:8080/bootstrap.min.css,去掉/styles试试