Ошибка при добавлении cookie в Spring
Прошу помощи в добавлении куки. Пишу интернет магазин и необходимо реализовать корзину с помощью файлов куки. Сейчас, при тестировании, я пытаюсь их добавить напрямую. Но вылетает эта ошибка:
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: org.thymeleaf.exceptions.TemplateInputException: Error resolving template [Username is changed!], template might not exist or might not be accessible by any of the configured Template Resolvers] with root cause
org.thymeleaf.exceptions.TemplateInputException: Error resolving template [Username is changed!], template might not exist or might not be accessible by any of the configured Template Resolvers
Контроллеры:
//добавляет значение куки
@GetMapping("/change-name")
public String setCookie(HttpServletResponse response, @RequestParam String name) {
// create a cookie
Cookie cookie = new Cookie("name", "hoody");
//add cookie to response
response.addCookie(cookie);
return "Username is changed!";
}
//выводит значение
@GetMapping("/name")
public String readCookie(@CookieValue(value = "name") String name) {
return "Hey! My username is " + name;
}
позже будет обращение к переменной через форму.
Подскажите, пожалуйста, в чем причина ошибки и какие варианты ее исправить
Источник: Stack Overflow на русском