Commit 0b9f2fff authored by yanzg's avatar yanzg

异常处理显示

parent 6e0db497
......@@ -87,10 +87,7 @@ public class CookiesHelper {
HttpServletResponse response = getResposne();
String toValue = URLEncoder.encode(value, CHARSET);
if (toValue.length() < ITEM_MAX_SIZE) {
// 创建cookie对象
Cookie cookie = new Cookie(key, toValue);
// 服务器把cookie响应给客户端,所有的cookie对象,都会在服务器端创建,通过http响应给客户端(浏览器)
response.addCookie(cookie);
addCookie(response, key, toValue);
} else {
int page = StringHelper.getPage(toValue.length(), ITEM_MAX_SIZE);
{
......@@ -104,12 +101,27 @@ public class CookiesHelper {
int size = Math.min(page - start, ITEM_MAX_SIZE);
int end = start + size - 1;
String itemValue = toValue.substring(start, end);
Cookie cookie = new Cookie(itemKey, itemValue);
response.addCookie(cookie);
addCookie(response, itemKey, itemValue);
}
}
}
/**
* 添加Cookies缓存
*
* @param key 键
* @param value 值
*/
private static void addCookie(HttpServletResponse response, String key, String value) {
// 创建cookie对象
Cookie cookie = new Cookie(key, value);
// 设置根目录生效
cookie.setPath("/");
cookie.setDomain("*");
// 服务器把cookie响应给客户端,所有的cookie对象,都会在服务器端创建,通过http响应给客户端(浏览器)
response.addCookie(cookie);
}
/**
* 获取请求对象
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment