通配URL*(可代表任何字符串)

例如:

app.get('/test/*', function(req, res){

  res.send(req.query.aa);

})

'/test/*通配test/...的URL

 

占位符URL(匹配一级)

例如:

app.get('/test/:a', function(req, res){

  res.send(req.query.aa);

})

'/test/*匹配test/a, test/b等的URL不匹配test/a/b

 

req参数获取:

req.query 处理get请求

req.params 处理/:xxx形式的get请求

req.body 处理post请求

req.param() 可以处理get和post请求,查找优先级为req.params-->req.body-->req.query

相关文章:

  • 2021-12-02
  • 2022-02-10
  • 2021-07-21
  • 2021-10-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-23
猜你喜欢
  • 2021-10-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-02
  • 2021-09-19
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案