顯示上次瀏覽過的商品資訊

2021-06-01 08:18:59 字數 1518 閱讀 5464

//宣告返回值變數

string goodshistory =null;

//獲取cookie物件

cookie cookies = request.getcookies();

//遍歷cookie物件

for(inti=0;cookies!=null&&i//判斷

if("goodshistory".equals(cookies[i].getname()))

}/*只儲存不同的三次瀏覽資訊

* * 第一次訪問:gooodhistory=null; goodshistory=id1

* * 第二次訪問:

*         兩次訪問的id不同        goodshistory=id2_id1

*         兩次訪問的id相同        goodshistory=id2

* 第三次訪問:

*         和第一次訪問的相同      goodshistory=id3_id2

*         和第二次訪問的id相同    goodshistory=id3_id1

*         和前兩次訪問的id都不同   goodshistory=id3_id2_id1*/

if(goodshistory==null)elseelseelse

}stringbuffer sb =newstringbuffer();

for(string id:li)

sb.deletecharat(sb.length()-1);

goodshistory=sb.tostring();

}//修改返回值變數

returngoodshistory;

/*傳送cookie

* 顯示瀏覽過的資訊

* */

//宣告瀏覽過商品的value值

stringvalue =null;

//獲取cooike

cookie cookies = request.getcookies();

//遍歷cookie資訊

for(inti=0;cookies!=null&&iif("goodshistory".equals(cookies[i].getname()))

}//判斷瀏覽過的value資訊是否存在

if(value!=null)

out.print("");

顯示瀏覽過的商品

顯示瀏覽過的商品 在商品列表顯示servlet中 listentities gservice.findall 通過findall方法查詢出所有商品 輸出顯示所有商品 for goodsentity entities 顯示瀏覽過的商品資訊 宣告瀏覽過的商品的value值 stringvalue nul...

python抓取京東的商品資訊

1.安裝python開發環境 2.requests庫 beautifulsoup庫 3.具備python一定基礎 1.經過分析可以知道keywork為搜尋關鍵字 2.page引數為篩選商品的頁下標,每頁30條資料 3.ev引數為篩選商品的 引數 1.我們發現商品的資料是訪問url直接返回來的 所以我...

瀏覽過的商品的簡單實現

listentities gservice.findall 通過 findall 方法查詢出所有商品 輸出顯示所有商品 for goods entity entities 顯示瀏覽過的商品資訊 宣告瀏覽過的商品的 value 值string value null cookie cookies req...