我写了下一个代码:
public void delete(MyType instance) {
List<MyType> myList = this.getAll();
Cookie[] cookies = request.getCookies();
List<Cookie> cookieList = new ArrayList<Cookie>();
cookieList = Arrays.asList(cookies);
for(Cookie cookie:cookieList) {
if(Long.valueOf(cookie.getValue()) == instance.getId()) {
cookieList.remove(cookie);
}
}
myList.remove(instance);
cookies = (Cookie[]) cookieList.toArray();
}
下一个问题是:当我从 cookielist 中删除 cookie 时,如何将更新的 cookielist(没有删除的 cookie)放回客户端?request 或 response 没有任何*.setCookies();
方法。还是cookies会自动更新?此致。