0
如果我在首页实现表单处理,系统显示错误。app.post快速入门 - Node.js
守则快递
var http = require('http'),
express = require('express'),
app = express();
app.use(express.bodyParser());
// A route for the home page - and the page with a form
app.post('/', function(req, res) {
// Code for Handling the form
});
表:
<form action="/" method="post"> . . . </form>
现在我得到这个错误:
不能得到/
我该如何解决这个问题?一些想法?
为完整的路由更新 - 与翡翠
// Set the view engine
app.set('view engine', 'jade');
// Where to find the view files
app.set('views', './views');
// A route for the home page - will render a view
app.post('/', function(req, res) {
res.render('index');
});
这里的表单代码:
<form action="/" method="post">
<label>Name</label>
<input type="text" name="name">
<label>Text</label>
<textarea name="text" rows="10"></textarea>
<input type="submit">
</form>
向我们显示主页和'带表单的页面'的路线。 – robertklep