koa-router post请求接收的参数为空

注:koa-router路由和koa-bodyparser中间件  post请求中参数为空。

 

 

页面代码

<!DOCTYPE html>
<html>
<head>
    <title>新增数据</title>
</head>
<body>
    <h1><%= title %></h1>
    <form method="post" action="/addCommit">
        <span>名字:</span>
        <input type="text"/>
        <span>描述:</span>
        <input type="text"/>
        <button type="submit">提交</button>
    </form>
</body>
</html>

上面这段代码,试了好多次,参数都接收不到。然后各种百度,找了半个多小时。还是没效果。

因为学过java 有点java基础  发现上面input输入框少了点 东西 "name"属性,然后就去试了一下。结果是成功了

<!DOCTYPE html>
<html>
<head>
    <title>新增数据</title>
</head>
<body>
    <h1><%= title %></h1>
    <form method="post" action="/addCommit">
        <span>名字:</span>
        <input type="text" name="nane"/>
        <span>描述:</span>
        <input type="text" name="message"/>
        <button type="submit">提交</button>
    </form>
</body>
</html>

不过 ,接收不到参数的原因有很多,这只是其中一个原因,而且还是最基础的......

总结:学习某种新技术时,要学会和其它技术去比较,“去类比“ 。

转载于:https://www.cnblogs.com/Mrrabbit/p/8733162.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值