手把手做一個JSP入門程式(四):商品實體類設計(JSP)

來源:互聯網
上載者:User
商品實體類設計

  這裡的商品執行個體也就是書籍。我們會將其構建為一個JavaBean類,以提高代碼的重複利用性和程式的可維護性。這裡有個小技巧用於迅速添加大量的setter和getter:右鍵你的類名,然後在快顯功能表中選擇:”Source” -> “Generate Getters and Setters” -> “Select All” -> “OK”。

package entity;import java.util.Date;public class Book {//  書籍的相關屬性,這裡需要設定為私人許可權    private String isbn;    private String name;    private String author;    private String intro; //書籍簡介    private float price_original;    private float price;    private String publish_comany;    private Date publish_time;    private String img_path;//  共有無參建構函式    public Book(){          }//  所有屬性的getter和setter    public String getIsbn() {        return isbn;    }    public void setIsbn(String isbn) {        this.isbn = isbn;    }    public String getName() {        return name;    }    public void setName(String name) {        this.name = name;    }    public String getAuthor() {        return author;    }    public void setAuthor(String author) {        this.author = author;    }    public String getIntro() {        return intro;    }    public void setIntro(String intro) {        this.intro = intro;    }    public float getPrice_original() {        return price_original;    }    public void setPrice_original(float price_original) {        this.price_original = price_original;    }    public float getPrice() {        return price;    }    public void setPrice(float price) {        this.price = price;    }    public String getPublish_comany() {        return publish_comany;    }    public void setPublish_comany(String publish_comany) {        this.publish_comany = publish_comany;    }    public Date getPublish_time() {        return publish_time;    }    public void setPublish_time(Date publish_time) {        this.publish_time = publish_time;    }    public String getImg_path() {        return img_path;    }    public void setImg_path(String img_path) {        this.img_path = img_path;    }}

你可以在點擊這裡查看更多關於JavaBean的知識。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.