나는 express를 사용 중이며 bodyParser에서 양식 데이터를 가져 오는 데 문제가 있습니다. 내가 뭘 할지라도 항상 빈 객체로 나타납니다. 나는를 제출하면Node.js/Express form post req.body not working
<!doctype html>
<html>
<body>
<form id="myform" action="/" method="post" enctype="application/x-www-form-urlencoded">
<input type="text" id="mytext" />
<input type="submit" id="mysubmit" />
</form>
</body>
</html>
: 여기
var express = require('express');
var app = module.exports = express.createServer();
// Configuration
app.configure(function(){
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(__dirname + '/public'));
});
app.configure('development', function(){
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});
app.configure('production', function(){
app.use(express.errorHandler());
});
// Routes
app.get('/', function(req, res){
res.sendfile('./public/index.html');
});
app.post('/', function(req, res){
console.log(req.body);
res.sendfile('./public/index.html');
});
app.listen(3010);
내 HTML 양식입니다 : 여기 내 표현이 app.js 코드를 생성이다 (I 추가 한 유일한 것은 하단에있는 app.post 노선이었다) 형태 req.body은 빈 개체 {}이 내가 양식 태그
에서에 enctype 속성을 제거 할 경우에도 발생하는 것을주의 그것의 가치가
... 내가 놓친 거지 뭔가 거기에가/잘못하고있다?
내가 노드 v0.4.11 및 표현 v2.4.6
고맙습니다! 어떻게 내가 그것을 간과하는지에 관해 명확히하지 않는다. .. – binarymax