[J2EE] servlet的cookie問題
請問
cookie的字串是不是不能包含空格?
因為我想把日期寫到cookie裡面 但是一直失敗
後來發現字串裡面有空格
在temoporary internetfiles裡面就會找不到
但是api裡面沒有寫到這個
好像只有寫到name的限制
Constructs a cookie with a specified name and value.
The name must conform to RFC 2109. That means it can contain only ASCII
alphanumeric characters and cannot contain commas, semicolons, or white space
or begin with a $ character. The cookie's name cannot be changed after
creation.
The value can be anything the server chooses to send. Its value is probably
of interest only to the server. The cookie's value can be changed after
creation with the setValue method.
以下是程式碼
final int AGE = 180000;
Date date = new Date();
Cookie Visiteddate = new Cookie("Visiteddate",date.toString());
Visiteddate.setMaxAge(AGE);
response.addCookie(Visiteddate);
這樣寫法會寫不進去...
但是只要把date裡面的月份日期抓出來
只要不包含空格就可以存了
只是這樣很麻煩...
請問cookie有這樣的限制嗎?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.161.208.233
推
01/01 12:30, , 1F
01/01 12:30, 1F