如何在邮递员中看到饼干?

时间:2016-10-19 06:32:34

标签: spring-mvc cookies postman

这是我在控制台登录的帖子。

@RequestMapping(value = EWPRestContants.SAY_HELLO, method = RequestMethod.POST, consumes=MediaType.APPLICATION_XML_VALUE,produces=MediaType.TEXT_PLAIN_VALUE)
@ResponseBody
public String sayHello(  HttpServletRequest request, HttpServletResponse response) throws Exception {

    Cookie[] cookies = request.getCookies();
    if (cookies != null) {
        for(Cookie cookie : cookies){
            System.out.println(cookie.getName() + "=" + cookie.getValue());
    }
    }

    Cookie newCookie = new Cookie("testCookie", "testCookieValue");
    newCookie.setMaxAge(24 * 60 * 60);
    response.addCookie(newCookie);
    return  "hello";
}

我在响应正文中看到“hello”返回。状态为200 OK。但我的cookie没有截获。请帮我。

我的邮差测试脚本是

var cookieValue = postman.getResponseCookie("testCookie").value; tests["cookie-value = " + cookieValue] = true;

为什么我无法拦截cookie?如何从服务器获取响应cookie?

0 个答案:

没有答案