mirror of
https://gitee.com/wkeyuan/DWSurvey.git
synced 2024-11-30 02:58:55 +08:00
cookie作用域修改
This commit is contained in:
parent
d1648b56b9
commit
f6e06632a8
@ -7,7 +7,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
public class CookieUtils {
|
||||
/**
|
||||
* 添加cookie
|
||||
*
|
||||
*
|
||||
* @param response
|
||||
* @param name
|
||||
* Cookie的名称,不能为null
|
||||
@ -34,27 +34,6 @@ public class CookieUtils {
|
||||
|
||||
response.addCookie(cookie);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置cookie
|
||||
*
|
||||
* @param response
|
||||
* @param name
|
||||
* cookie名字
|
||||
* @param value
|
||||
* cookie值
|
||||
* @param maxAge
|
||||
* cookie生命周期 以秒为单位
|
||||
*/
|
||||
public static void addCookie(HttpServletResponse response, String name,
|
||||
String value, int maxAge) {
|
||||
Cookie cookie = new Cookie(name, value);
|
||||
cookie.setPath("/");
|
||||
if (maxAge > 0)
|
||||
cookie.setMaxAge(maxAge);
|
||||
response.addCookie(cookie);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param request
|
||||
|
@ -197,8 +197,9 @@ public class DwsAnswerAction extends ActionSupport {
|
||||
entity.setDataSource(0);
|
||||
surveyAnswerManager.saveAnswer(entity, quMaps);
|
||||
int effe = surveyDetail.getEffectiveTime();
|
||||
|
||||
CookieUtils.addCookie(response, surveyId, (ipNum + 1) + "",
|
||||
effe * 60, "/");
|
||||
effe * 60, request.getContextPath());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return RELOAD_ANSWER_FAILURE;
|
||||
@ -248,7 +249,7 @@ public class DwsAnswerAction extends ActionSupport {
|
||||
|
||||
int effe = surveyDetail.getEffectiveTime();
|
||||
CookieUtils.addCookie(response, surveyId, (ipNum + 1) + "",
|
||||
effe * 60, "/");
|
||||
effe * 60, request.getContextPath());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return RELOAD_ANSWER_FAILURE;
|
||||
@ -465,4 +466,4 @@ public class DwsAnswerAction extends ActionSupport {
|
||||
this.surveyId = surveyId;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user