<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<form action="http://localhost:3000" method="get">
username <input type="text" name="user" value=""><br>
password <input type="password" name="pass" value=""><br>
<input type="submit" value="send">
</form>
</body>
</html>
GET数据是存在req.query上的,所以输出req.query输出GET数据.
const express=require('express');
var server=express();
server.listen(3000);
//express的GET数据存在req.query中
server.use('/', function(req,res){
console.log(req.query);//输出{ user: 'ccs', pass: '123' }
});
网友评论