开发者社区 问答 正文

springmvc中cookie的测试? 400 报错

springmvc中cookie的测试? 400 报错 springmvc中可以使用Mock的request, response来测试请求。但是如果想测试cookie呢?

展开
收起
爱吃鱼的程序员 2020-06-02 17:10:04 550 分享 版权
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    个人认为cookie 是要从请求里面拿的。 你可以写一个类去实现org.springframework.web.bind.support.WebArgumentResolver这个类,再把HttpServeletReuqest注入到NativeWebRequest 里面 然后把NativeWebRequest 转换成HttpServeletRequest就可以处理cookie了。

    2020-06-02 17:10:22
    赞同 展开评论