1. <ul id="0c1fb"></ul>

      <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
      <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区

      RELATEED CONSULTING
      相關(guān)咨詢
      選擇下列產(chǎn)品馬上在線溝通
      服務(wù)時間:8:30-17:00
      你可能遇到了下面的問題
      關(guān)閉右側(cè)工具欄

      新聞中心

      這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
      教你使用cookie法,查看最近看過的書-創(chuàng)新互聯(lián)

      教你使用cookie法,查看最近看過的書
      import java.io.Serializable;

      成都創(chuàng)新互聯(lián)公司是專業(yè)的宜章網(wǎng)站建設(shè)公司,宜章接單;提供成都做網(wǎng)站、成都網(wǎng)站設(shè)計,網(wǎng)頁設(shè)計,網(wǎng)站設(shè)計,建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進行宜章網(wǎng)站開發(fā)網(wǎng)頁制作和功能擴展;專業(yè)做搜索引擎喜愛的網(wǎng)站,專業(yè)的做網(wǎng)站團隊,希望更多企業(yè)前來合作!

      public class Book implements Serializable {
      private String id;
      private String name;
      private String price;
      private String auth;
      private String publish;
      private String description;

      public Book() {
      }

      public Book(String id, String name, String price, String auth,
      String publish, String description) {
      super();
      this.id = id;
      this.name = name;
      this.price = price;
      this.auth = auth;
      this.publish = publish;
      this.description = description;
      }

      public String getDescription() {
      return description;
      }

      public void setDescription(String description) {
      this.description = description;
      }

      public String getId() {
      return id;
      }
      public void setId(String id) {
      this.id = id;
      }
      public String getName() {
      return name;
      }
      public void setName(String name) {
      this.name = name;
      }
      public String getPrice() {
      return price;
      }
      public void setPrice(String price) {
      this.price = price;
      }
      public String getAuth() {
      return auth;
      }
      public void setAuth(String auth) {
      this.auth = auth;
      }
      public String getPublish() {
      return publish;
      }
      public void setPublish(String publish) {
      this.publish = publish;
      }

      }
      public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
      response.setContentType("text/html;charset=utf-8");
      //1.獲取要看的書的id,查詢數(shù)據(jù)庫找出書,輸出書的詳細(xì)信息
      String id = request.getParameter("id");
      Book book = BookDao.getBook(id);
      if(book==null){
      response.getWriter().write("找不到這本書!");
      return;
      }else{
      response.getWriter().write("

      書名:"+book.getName()+"

      ");
      response.getWriter().write("

      作者:"+book.getAuth()+"

      ");
      response.getWriter().write("

      售價:"+book.getPrice()+"

      ");
      response.getWriter().write("

      出版社:"+book.getPublish()+"

      ");
      response.getWriter().write("

      描述信息:"+book.getDescription()+"

      ");
      }

      //2.發(fā)送cookie保存最后看過的書
      // --- 1 --> 1
      // 1 --2,1 --> 2,1
      // 2,1--3,2,1 --> 3,2,1
      // 3,2,1 -- 4,3,2 --> 4,3,2
      // 4,3,2 --3,4,2 --> 3,4,2
      String ids = "";

      Cookie [] cs = request.getCookies();
      Cookie findC = null;
      if(cs!=null){
      for(Cookie c : cs){
      if("last".equals(c.getName())){
      findC = c;
      }
      }
      }

      if(findC == null){
      //說明之前沒有看過書的記錄
      ids += book.getId();
      }else{
      //說明之前有歷史看過的書的記錄,需要根據(jù)歷史記錄算一個新的記錄出來
      String [] olds = findC.getValue().split(",");
      StringBuffer buffer = new StringBuffer();
      buffer.append(book.getId()+",");
      for(int i = 0;iString old = olds[i];
      if(!old.equals(book.getId())){
      buffer.append(old+",");
      }
      }
      ids = buffer.substring(0, buffer.length()-1);
      }

      Cookie lastC = new Cookie("last",ids);
      lastC.setMaxAge(36002430);
      lastC.setPath(request.getContextPath());
      response.addCookie(lastC);
      }教你使用cookie法,查看最近看過的書


      文章題目:教你使用cookie法,查看最近看過的書-創(chuàng)新互聯(lián)
      文章分享:http://www.ef60e0e.cn/article/hhoos.html
      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区
      1. <ul id="0c1fb"></ul>

        <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
        <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

        绥化市| 贺州市| 瑞安市| 沭阳县| 顺昌县| 饶河县| 城固县| 自贡市| 鄱阳县| 长治市| 阿勒泰市| 贵阳市| 平遥县| 珠海市| 汉寿县| 临夏市| 凤台县| 邵武市| 布拖县| 兴义市| 双流县| 慈溪市| 青神县| 黄石市| 萍乡市| 宁武县| 裕民县| 梅河口市| 盈江县| 南安市| 侯马市| 呼玛县| 竹溪县| 营山县| 江门市| 新津县| 海丰县| 红原县| 嘉义县| 永年县| 彰化县|