目录

重置密码问题记录

目录

重置密码问题记录

昨天晚上,我写了重置密码的前端,测试的时候报错

https://i-blog.csdnimg.cn/blog_migrate/2efd8072fde9eebf2acc628fc6ea3f6c.png

今天上午,我继续试图解决这个问题,我仔细检查了一遍,前端没有问题

https://i-blog.csdnimg.cn/blog_migrate/cb5a6d0b0a91a0e1c9c862f621c0da52.png

可以正常接收输入的数据并且提交 https://i-blog.csdnimg.cn/blog_migrate/4419feeb42ec6cc220b56b5c92de6d79.png

但是后端接收到的数据为空,后端接口也没有问题

https://i-blog.csdnimg.cn/blog_migrate/29b3599409b21eaea72e55f209d77160.png

但后端收到的数据为空 https://i-blog.csdnimg.cn/blog_migrate/401f05dc8d96f670c8c58c7968360e6f.png

随后我又用postman测试了一下,把字段名改了一下

https://i-blog.csdnimg.cn/blog_migrate/3dd8a4be2eeeb29fd711f09462797767.png

发现了同样的错误,后端显示第一个字段为空,后两个有值

https://i-blog.csdnimg.cn/blog_migrate/9b8c54c9a1835c106dc1dc4225189ed6.png

这时在看一下前端数据

https://i-blog.csdnimg.cn/blog_migrate/c4238f26bbde0883071999f4060f77d9.png

发现了问题所在,就是后端的PasswordDto这个类的字段是oldPwd,newPwd,rePwd  而前端传来的数据是oldPassword,字段对不上,所以后端接收到的数据为空

需要把前端的字段改成和后端一样

改之前

https://i-blog.csdnimg.cn/blog_migrate/29e09122ee8b0fb015d4d96294ad74b3.png

改之后

https://i-blog.csdnimg.cn/blog_migrate/0ed40b6d37f4c89b4db7fde00a22e413.png

再次测试修改密码

https://i-blog.csdnimg.cn/blog_migrate/e76432d3559f42b9fff76668e28d550d.png

成功

总结:前端返回的字段名要和后端一致,不然后端没法接受数据,这个错误耗了很久,不过以后应该不会再犯了