当前位置: 网站首页 > WEB > jsp

实例讲解JSP Model2体系结构(中)

时间:1970-1-1 08:33:31来源: jsp作者:admin 点击:0次 字体 [ С]

    }

   }

   private CD getCD(HttpServletRequest req) {

    //想象一下如果这些都在一个脚本片段中会有多么难看

    String myCd = req.getParameter("CD");

    String qty = req.getParameter("qty");

    StringTokenizer t = new StringTokenizer(myCd,"|");

    String album= t.nextToken();

    String artist = t.nextToken();

    String country = t.nextToken();

    String price = t.nextToken();

    price = price.replace('$',' ').trim();

    CD cd = new CD();

    cd.setAlbum(album);

    cd.setArtist(artist);

    cd.setCountry(country);

    cd.setPrice((new Float(price)).floatValue());

    cd.setQuantity((new Integer(qty)).intValue());

    return cd;

   }

  }

发表评论
验证码:
最新评论
相关文章
最热文章