Здравствуйте, вначале куки вроде устанавливаются, но в метод ttt не передаются. Подскажите, в чем ошибка?
@Controller
public class MyController {
@RequestMapping("/qwe/{id}")
public String qwe(@PathVariable("id") Integer id,
HttpServletResponse response) {
Cookie cookie = new Cookie("buy", id.toString());
cookie.setMaxAge(500);
response.addCookie(cookie);
return "redirect:/ttt";
}
@RequestMapping("/ttt")
public ModelAndView ttt(ModelAndView model,
@CookieValue(value = "buy") String cookie,
HttpServletRequest request) {
model.addObject("cookie", cookie);
model.setViewName("view");
return model;
}
}
view.jsp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<p>${cookie}</p>
</body>
</html>
ошибка:
HTTP Status [400] – [Bad Request]
Missing cookie 'buy' for method parameter of type String
The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).
Сборка персонального компьютера от Artline: умный выбор для современных пользователей