帶分頁功能的SSH整合,DAO層經典封裝

任何一個封裝講究的是,使用,多狀態。
Action:
任何一個Action繼承分頁有關參數類PageManage,自然考慮的到分頁效果,我們必須定義下幾個分頁的參數。并根據這個參數進行查值。
然后在繼承ServiceManage,ServiceManage類是用來 存放共用的東西:response,重要的是Service的get set
具體講一下PageManage,
totalPages;//總頁數
totalRecord;//總記錄數
showRecordNum=DEFAULT_PAGE_NUM;//每頁顯示記錄數
showPageNum;//當前頁顯示的記錄數量
 
public class PageManage extends ServiceManage{/*** 分頁的一些參數* @author sl*/
private static final long serialVersionUID = 1L;// 以下三個參數是分頁需返回
// protected int currentPage = 1; // 當前頁數
protected int totalPages; // 總頁數
protected int totalRecord; // 總記錄數
protected int pageNum = 1; // 當前頁數//默認每頁的數量
protected int numPerPage = 20; protected PageUtil pageUtil(int totalRecord_) {
return new PageUtil(pageNum, totalRecord_, numPerPage);
}//一些getset方法
public int getTotalPages() {
return totalPages;
}
public void setTotalPages(int totalPages) {
this.totalPages = totalPages;
}
public int getTotalRecord() {
return totalRecord;
}
public void setTotalRecord(int totalRecord) {
this.totalRecord = totalRecord;
}
public int getPageNum() {
return pageNum;
}
public void setPageNum(int pageNum) {
this.pageNum = pageNum;
}
public int getNumPerPage() {
return numPerPage;
}
public void setNumPerPage(int numPerPage) {
this.numPerPage = numPerPage;
}}
View Code

其中涉及到的?PageUtil,這就分頁的參數設置,和進行分頁功能的一些邏輯判斷,邏輯變動。

PageUtil:

PageUtil(Integer currentPage,Integer totalRecord,int showRecordNum)這個定義了一個page 以后調用就這個。
//分頁用到的基本兩個參數:1.總的記錄條數 ?2.每頁的記錄條數
DEFAULT_CURRENT=1;?//默認顯示第一頁
DEFAULT_PAGE_NUM=20;//默認顯示20條記錄
pageFirRecord=0;//當前頁第一條記錄
currentPage=1;//當前頁數
totalPages;//總頁數
totalRecord;//總記錄數
showRecordNum=DEFAULT_PAGE_NUM;//每頁顯示記錄數
showPageNum;//當前頁顯示的記錄數量
prePage=1;
nexePage=1;
public class PageUtil{
//分頁用到的基本兩個參數:1.總的記錄條數  2.每頁的記錄條數
//public static final Integer DEFAULT_CURRENT=1; //默認顯示第一頁
public static final Integer DEFAULT_PAGE_NUM=20;//默認顯示20條記錄protected Integer pageFirRecord=0;//當前頁第一條記錄
protected Integer currentPage=1;//當前頁數
protected Integer totalPages;//總頁數
protected Integer totalRecord;//總記錄數
protected Integer showRecordNum=DEFAULT_PAGE_NUM;//每頁顯示記錄數
protected Integer showPageNum;//當前頁顯示的記錄數量
protected Integer prePage=1;
protected Integer nexePage=1;
public PageUtil(){}public PageUtil(Integer currentPage,Integer totalRecord){//兩個參數,一個是當前頁數,一個是總頁數this.setTotalRecord(totalRecord);//調用set()方法來將參數賦值
this.setTotalPages();
this.setCurrentPage(currentPage);this.setShowPageNum();
this.setPageFirRecord();
this.setPrePage();
this.setNexePage();
}
/*** 重載* @param currentPage* @param totalRecord* @param showRecordNum*/
public PageUtil(Integer currentPage,Integer totalRecord,int showRecordNum){   //showRecordNum:為當前頁的總記錄條數this.setTotalRecord(totalRecord);
this.setShowRecordNum(showRecordNum);
this.setTotalPages();
this.setCurrentPage(currentPage);this.setShowPageNum();
this.setPageFirRecord();this.setPrePage();//計算前一頁頁碼
this.setNexePage();//計算下一頁頁碼
}
public Integer getPrePage() {
return prePage;
}
public void setPrePage() {//設置前一頁的頁碼
this.prePage = currentPage-1;//為當前頁數減1
}public Integer getNexePage() {
return nexePage;
}
public void setNexePage() {if(currentPage==totalPages){  //如果當前頁碼為總頁碼,即最后一頁
this.nexePage = 0;//返回0
}else{
this.nexePage = currentPage+1;//當前頁加1
}
if(totalPages==0){//如果總頁數為0,怎么返回0;
this.nexePage = 0;
}
}public Integer getShowPageNum() {//返回當前頁顯示的記錄數量
return showPageNum;
}
public void setShowPageNum() {//當前頁顯示的記錄數量
if(currentPage*showRecordNum-totalRecord>0){//當前頁數*每頁顯示的條數—總的記錄條數>0 表示現在已經是最后一頁了
this.showPageNum = totalRecord-(currentPage-1)*showRecordNum;
}else{
this.showPageNum=showRecordNum;
}}public Integer getShowRecordNum() {//返回每頁的記錄條數
return showRecordNum;
}
public void setShowRecordNum(Integer showRecordNum) {
this.showRecordNum = showRecordNum;
}public Integer getTotalPages() {//返回總的頁數
return totalPages;
}
public void setTotalPages() {//計算總頁數
if(totalRecord%showRecordNum==0){
this.totalPages = totalRecord/showRecordNum;
}else{
this.totalPages = totalRecord/showRecordNum+1;
}}public Integer getTotalRecord() {//返回總的記錄條數
return totalRecord;
}
public void setTotalRecord(Integer totalRecord) {
this.totalRecord = totalRecord;
}public Integer getCurrentPage() {//返回當前的頁數
return currentPage;
}
public void setCurrentPage(Integer currentPage) {if(currentPage==0||currentPage<0){
currentPage=1;
}
if(currentPage>totalPages&&totalPages!=0){
this.currentPage=totalPages;//當前頁大于總頁數時為總頁數,并且保證不存在記錄時不出錯,即totalPages!=0
}else if(totalPages==0){
this.currentPage=1;
}else{
this.currentPage = currentPage;
}
}public void setPageFirRecord() {//第一條記錄所在集合的標號,比實際排數少一
this.pageFirRecord = (getCurrentPage()-1)*showRecordNum;//第一條記錄為當前頁的前一頁*每頁顯示的記錄數
}
public Integer getPageFirRecord() {//返回第一條記錄
return pageFirRecord;
}}
View Code

?


然后講Service層:
只要繼承一個父類CURDS;CURDS類里面的方法和封裝好的DAO層hibernate帶分頁的分裝方法一致
隨便一個service層接口
一般的方法自然都在CURDS有了。以下是寫一個特殊的方法
List<AuthApply> getApplie():
所以一般來說,CURDS里面的方法夠用了。
public interface AuthApplyS extends CURDS<AuthApply>{
/**
* 根據認證的類型與狀態獲取相應的認證申請
* */
public List<AuthApply> getApplie(String type, String status, Integer memberId);
}

CURDS:? ? 里面的方法是Service共用的方法

/**
* 根據條件集合大小,這里使用java 1.5引入的新特性:可變參數
* */
public int getNums(Object ...args);
/**
* 根據條件集合
* */
public List<T> getList(PageUtil pageUtil, Object ...args);
/**
* 保存對象
* */
public T makePersitent(T entity);?
/**
* 根本編號獲得對象
* */
public T findById(Integer id);
public interface CURDS<T> {
/*** 根據條件集合大小,這里使用java 1.5引入的新特性:可變參數* */
public int getNums(Object ...args);
/*** 根據條件集合* */
public List<T> getList(PageUtil pageUtil, Object ...args);
/*** 保存對象* */
public T makePersitent(T entity); 
/*** 根本編號獲得對象* */
public T findById(Integer id);
}
View Code

?

?service層實現:
????共用的CURDS接口里面的方法里面如果要用就實現,不用不需要?
? DAOManage:只是DAO接口的注入
public class AuthApplySI extends DAOManage implements AuthApplyS{public AuthApply findById(Integer id) {
return authApplyD.findById(id);
}public List<AuthApply> getList(PageUtil pageUtil, Object... args) {
return authApplyD.findByPage(getHQL((String)args[0]), pageUtil.getPageFirRecord(), pageUtil.getShowRecordNum());
}public int getNums(Object... args) {
return authApplyD.findByPage(getHQL((String)args[0]), 0, 0).size();
}private String getHQL(String type){
StringBuffer hql = new StringBuffer("from AuthApply as auth where auth.authType = '"+type+"'");
hql.append(" and auth.status = '"+AuthCon.SUBMIT_AUTH+"'");
return hql.toString();
}public AuthApply makePersitent(AuthApply entity) {
return authApplyD.makePersitent(entity);
}public List<AuthApply> getApplie(String type, String status, Integer memberId) {
StringBuffer hql = new StringBuffer("from AuthApply as auth where auth.authType = '"+type+"' and auth.status = '"+status+"'");
if(memberId != null){
hql.append(" and auth.member.memberId = "+memberId);
}
return authApplyD.findByPage(hql.toString(), 0, 0).size() == 0? null: authApplyD.findByPage(hql.toString(), 0, 0);
}}
View Code

下面看一下 DAO層的封裝吧。

?經典的終于來了。前面注意分頁的那些類:
首先 因為有一些是特殊的方法,所以我們也要定義
AuthApplyD接口:很簡單吧。
????AuthApply 是bean類??
????GenericDAO?這繼承的父類就是我們的封裝。
public interface AuthApplyD extends GenericDAO<AuthApply>{
}
AuthApplyD實現類
super(AuthApply.class);這個方法很重要,調用的是GenericHibernateDAO的方法,而將Bean類傳到DAO層。
public class AuthApplyDI extends GenericHibernateDAO<AuthApply> implements
AuthApplyD{public AuthApplyDI() {
super(AuthApply.class);//這super,就是調用父類的構造方法
}}
View Code
GenericDAO接口封裝:
這才是我想說的經典
  
/**
* 通過ID獲得實體對象
*?
* @param id實體對象的標識符
* @return 該主鍵值對應的實體對象
*/
T findById(Integer id);
T findById(Long id);
/**
* 將實體對象持久化
*?
* @param entity 需要進行持久化操作的實體對象
* @return 持久化的實體對象
*/
T makePersitent(T entity);?
/**
* 將實體變為瞬態
*?
* @param entity需要轉變為瞬態的實體對象
*/
void makeTransient(T entity);
/**
* 將一系列的實體變為瞬態,使用本地sql
*?
* @param hql
*/
void makeTransientByIds(String sql);
/**
*?
* 使用hql語句進行分頁操作
*?
* @param hql
* @param offset第一條記錄索引
* @param pageSize每頁需要顯示的記錄數
* @return查詢的記錄
*/
List<T> findByPage(final String hql,final int offset,final int pageSize);
/**
* 使用hql 語句進行分頁查詢操作
*?
* @param hql 需要查詢的hql語句
* @param value 如果hql有一個參數需要傳入,value就是傳入的參數
* @param offset 第一條記錄索引
* @param pageSize 每頁需要顯示的記錄數
* @return 當前頁的所有記錄
*/
List<T> findByPage(final String hql , final Object value ,
final int offset, final int pageSize);
/**
* 使用hql 語句進行分頁查詢操作
*?
* @param hql 需要查詢的hql語句
* @param values 如果hql有一個參數需要傳入,value就是傳入的參數
* @param offset 第一條記錄索引
* @param pageSize 每頁需要顯示的記錄數
* @return 當前頁的所有記錄
*/
List<T> findByPage(final String hql, final Object[] values,
final int offset, final int pageSize);
/**
* 使用sql 語句進行分頁查詢操作
*?
* @param sql
* @param offset
* @param pageSize
* @return
*/
List<T> findByPageSQL(final String sql,?
final int offset, final int pageSize);
/**
* 根據語句查找總數
* @param hql hql語句
* @return 對應的數目
*/
Integer getCount(String hql);
void updateObj(final String hql,final Object[] values);
/**
* 更新
* */
void updateEntity(T entity);
/**
* 返回list集合
* */
@SuppressWarnings("unchecked")
public List getListDataByHQL(String hql);
/**
* hql查詢單個字段
* */
public List<Object> findSingleDataByHQL(String hql);
/**
* hql查詢多個字段
* */
public List<Object[]> findSomeDataByHQL(String hql);
}
/**** @param <T>*/public interface GenericDAO <T>{
/*** 通過ID獲得實體對象* * @param id實體對象的標識符* @return 該主鍵值對應的實體對象*/
T findById(Integer id);
T findById(Long id);
/*** 將實體對象持久化* * @param entity 需要進行持久化操作的實體對象* @return 持久化的實體對象*/
T makePersitent(T entity); /*** 將實體變為瞬態* * @param entity需要轉變為瞬態的實體對象*/
void makeTransient(T entity);/*** 將一系列的實體變為瞬態,使用本地sql* * @param hql*/
void makeTransientByIds(String sql);/*** * 使用hql語句進行分頁操作* * @param hql* @param offset第一條記錄索引* @param pageSize每頁需要顯示的記錄數* @return查詢的記錄*/
List<T> findByPage(final String hql,final int offset,final int pageSize);/*** 使用hql 語句進行分頁查詢操作* * @param hql 需要查詢的hql語句* @param value 如果hql有一個參數需要傳入,value就是傳入的參數* @param offset 第一條記錄索引* @param pageSize 每頁需要顯示的記錄數* @return 當前頁的所有記錄*/
List<T> findByPage(final String hql , final Object value ,final int offset, final int pageSize);/*** 使用hql 語句進行分頁查詢操作* * @param hql 需要查詢的hql語句* @param values 如果hql有一個參數需要傳入,value就是傳入的參數* @param offset 第一條記錄索引* @param pageSize 每頁需要顯示的記錄數* @return 當前頁的所有記錄*/
List<T> findByPage(final String hql, final Object[] values,final int offset, final int pageSize);/*** 使用sql 語句進行分頁查詢操作* * @param sql* @param offset* @param pageSize* @return*/
List<T> findByPageSQL(final String sql, final int offset, final int pageSize);/*** 根據語句查找總數* @param hql hql語句* @return 對應的數目*/
Integer getCount(String hql);void updateObj(final String hql,final Object[] values);
/*** 更新* */
void updateEntity(T entity);
/*** 返回list集合* */
@SuppressWarnings("unchecked")
public List getListDataByHQL(String hql);
/*** hql查詢單個字段* */
public List<Object> findSingleDataByHQL(String hql);
/*** hql查詢多個字段* */
public List<Object[]> findSomeDataByHQL(String hql);
}
View Code
GenericHibernateDAO實現類:
public class GenericHibernateDAO<T> extends HibernateDaoSupport 
implements GenericDAO<T>{private Class<T> persistentClass;public GenericHibernateDAO(Class<T> persistentClass){
this.persistentClass=persistentClass;
}public Class<T> getPersistentClass(){
return persistentClass;
}public T findById(Integer id) {
return (T)getHibernateTemplate().get(getPersistentClass(), id);
}@SuppressWarnings("unchecked")
public List<T> findByPage(final String hql, final int offset, final int pageSize){
if(hql == null){
return new ArrayList<T>();
}
List<T> list= getHibernateTemplate().executeFind(new HibernateCallback(){
public Object doInHibernate(final Session session)
throws HibernateException, SQLException{
Query query=session.createQuery(hql);
if(!(offset==0 && pageSize==0)){
query.setFirstResult(offset).setMaxResults(pageSize);
}
List<T> result = query.list();
return result;
}
});
return list;
}@SuppressWarnings("unchecked")
public List findByPageSQL(final String sql, final int offset, final int pageSize){
List list= getHibernateTemplate().executeFind(new HibernateCallback(){
public Object doInHibernate(final Session session)
throws HibernateException, SQLException{
Query query=session.createSQLQuery(sql);
if(!(offset==0 && pageSize==0)){
query.setFirstResult(offset).setMaxResults(pageSize);
}
List result = query.list();
return result;
}
});
return list;
}@SuppressWarnings("unchecked")
public List<T> findByPage(final String hql, final Object value, 
final int offset, final int pageSize) {
List<T> list = getHibernateTemplate().executeFind(new HibernateCallback()
{
public Object doInHibernate(Session session)
throws HibernateException, SQLException
{
Query query=session.createQuery(hql).setParameter(0, value);
if(!(offset==0 && pageSize==0)){
query.setFirstResult(offset).setMaxResults(pageSize);
}
List<T> result = query.list();
return result;
}
});
return list;
}@SuppressWarnings("unchecked")
public List<T> findByPage(final String hql, final Object[] values, final int offset,
final int pageSize) {
List<T> list = getHibernateTemplate().executeFind(new HibernateCallback(){
public Object doInHibernate(Session session)
throws HibernateException, SQLException{
Query query=session.createQuery(hql);
for (int i = 0 ; i < values.length ; i++){
query.setParameter( i, values[i]);
}
if(!(offset==0 && pageSize==0)){
query.setFirstResult(offset).setMaxResults(pageSize);
}
List<T> result = query.list();
return result;
}
});
return list;
}@SuppressWarnings("unchecked")
public void updateObj(final String hql, final Object[] values) {
getHibernateTemplate().execute(new HibernateCallback(){
public Object doInHibernate(Session session)
throws HibernateException, SQLException{
Query query=session.createQuery(hql);
for(int i=0;i<values.length;i++){
query.setParameter( i, values[i]);
}
query.executeUpdate();
return null;
}
});
}public Integer getCount(String hql) {
Integer count;
//iterate方法與list方法的區別是list取出全部,iterator取出主鍵,迭代的時候才取出數據
count = ((Long)getHibernateTemplate().iterate(hql).next()).intValue();
System.out.println("大小"+ count);
return count;
}public T makePersitent(T entity) {
getHibernateTemplate().saveOrUpdate(entity);
return entity;
}public void makeTransient(T entity) {
getHibernateTemplate().delete(entity);
}@SuppressWarnings("unchecked")
public void makeTransientByIds(final String sql) {
getHibernateTemplate().execute(new HibernateCallback(){
public Object doInHibernate(Session session)
throws HibernateException, SQLException{
Query query=session.createQuery(sql);
query.executeUpdate();
return null;
}
});
}public T findById(Long id) {
return (T) getHibernateTemplate().get(getPersistentClass(), id);
}public void updateEntity(T entity) {
this.getHibernateTemplate().update(entity);
}
@SuppressWarnings("unchecked")
public List getListDataByHQL(String hql) {
return getHibernateTemplate().find(hql);
}/*** hql查詢單個字段* */
@SuppressWarnings("unchecked")
public List<Object> findSingleDataByHQL(String hql) {
return getHibernateTemplate().find(hql);
}
/*** hql查詢多個字段* */
@SuppressWarnings("unchecked")
public List<Object[]> findSomeDataByHQL(String hql) {
return getHibernateTemplate().find(hql);
}
}
View Code

希望首頁能再次通過,我修改下。

總結:帶分頁功能的SSH整合,DAO層經典封裝
  考慮前臺,一條線的傳到后臺,然后分工必須明確。
  DAO層的封裝,可見java底層的魅力。
共同開發,共同努力。

轉載于:https://www.cnblogs.com/Alandre/p/3366557.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/377723.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/377723.shtml
英文地址,請注明出處:http://en.pswp.cn/news/377723.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

在windows phone Mango中使用原生代碼開發程序

本文不討論創建可執行的exe程序,主要想說明怎么在silverlight程序里面調用由原生代碼所編寫的DLL(C / ARM). 原生代碼可以調用更多的API,但是這并不是說你就能隨意獲得那些你沒有權限的資源,比如,你可以使用CopyFile這個API,但是如果你試圖把文件Copy到\Windows文件夾,就會得到…

leetcode 198. 打家劫舍 思考分析

目錄1、題目2、求解思路3、代碼1、題目 你是一個專業的小偷&#xff0c;計劃偷竊沿街的房屋。每間房內都藏有一定的現金&#xff0c;影響你偷竊的唯一制約因素就是相鄰的房屋裝有相互連通的防盜系統&#xff0c;如果兩間相鄰的房屋在同一晚上被小偷闖入&#xff0c;系統會自動…

找不到Windows照片查看器解決方法

桌面創建一個txt文本 復制這些命令&#xff0c;之后將后綴改為.reg&#xff0c;右擊管理員身份運行即可 Windows Registry Editor Version 5.00 ; Change Extensions File Type [HKEY_CURRENT_USER\Software\Classes\.jpg] "PhotoViewer.FileAssoc.Tiff" ; Change E…

數字拆分為斐波那契數列_檢查數字是否為斐波那契

數字拆分為斐波那契數列Description: 描述&#xff1a; We are often used to generate Fibonacci numbers. But in this article, we are going to learn about how to search Fibonacci numbers in an array? 我們經常被用來產生斐波那契數。 但是在本文中&#xff0c;我們…

伙伴分配器的一個極簡實現

提起buddy system相信很多人不會陌生&#xff0c;它是一種經典的內存分配算法&#xff0c;大名鼎鼎的Linux底層的內存管理用的就是它。這里不探討內核這么復雜實現&#xff0c;而僅僅是將該算法抽象提取出來&#xff0c;同時給出一份及其簡潔的源碼實現&#xff0c;以便定制擴展…

[USACO3.2.3 Spinning Wheels]

[關鍵字]&#xff1a;模擬 枚舉 [題目大意]&#xff1a;有5個輪子&#xff0c;每個輪子優r個缺口并且會按一定速度不停轉動&#xff0c;問什么時候可以使一條光線射過所有輪子。 // [分析]&#xff1a;從0到1000&#xff08;或其他的&#xff09;枚舉分鐘然后判斷&#xff0c;當…

一、SQLServer2008安裝(帶密碼)、創建數據庫、C#窗體項目測試

一、下載和安裝SQLServer2008 東西太大了&#xff0c;沒法上傳到資源里面&#xff0c;官網其他公眾號都下載可以。 右擊管理員身份 運行setup.exe 這個密鑰不能用的話&#xff0c;也可以去百度其他密鑰 JD8Y6-HQG69-P9H84-XDTPG-34MBB 建議改一下路徑&#xff0c;我這邊修…

python獲取當前日期_Python程序獲取當前日期

python獲取當前日期In the below example – we are implementing a python program to get the current date. 在下面的示例中-我們正在實現一個python程序來獲取當前日期 。 Steps: 腳步&#xff1a; Import the date class from datetime module. 從datetime模塊導入日期類…

【C++grammar】多態、聯編、虛函數

目錄1、多態概念1.多態性有兩種表現的方式2、聯編&#xff08;實現多態&#xff09;1.靜態聯編2.動態聯編3、實現運行時多態1.為何要使用運行時多態&#xff1f;2.如何實現運行時多態3.多態的例子1.調用哪個同名虛函數&#xff1f;2. 用途&#xff1a;可以用父類指針訪問子類對…

一 MVC - HtmlHelper

HtmlHelper類位于System.Web.Mvc.Html之中主要有七個靜態類組成&#xff1a; FormExtensions - BeginForm, BeginRouteForm, EndForm InputExtensions - CheckBox, CheckBoxFor, Hidden, HiddenFor, Password, PasswordFor, RadioButton, RadioButtonFor, TextBox, TextBoxFor …

HDOJ 400題紀念。

剛剛交了1506&#xff0c;無意間瞟到左邊的隨筆數&#xff0c;發現已經401題了&#xff0c;這么說前幾天就400題了啊囧。 昨天還想交到400題就先放放&#xff0c;背單詞的&#xff0c;沒想到那么快。等把USACO那個八皇后寫完吧。人生總是有許多不想做又不得不做的事情。。。 還…

二、用戶登錄和注冊

一、頁面設計 一共四個頁面 主頁面Form1&#xff0c;登錄頁面login&#xff0c;注冊頁面resister&#xff0c;主菜單頁面main_page 系統運行進入Form1&#xff0c;單擊登錄按鈕跳轉到login&#xff0c;數據庫中得存在數據信息且輸入正確才可登錄成功&#xff0c;跳轉到main_pa…

readdir函數_PHP readdir()函數與示例

readdir函數PHP readdir()函數 (PHP readdir() function) The full form of readdir is "Read Directory", the function readdir() is used to read the directory i.e. read the name of the next entry in the directory. readdir的完整形式為“ Read Directory”…

【C++grammar】訪問控制與抽象類與純虛函數

目錄一、訪問控制 (可見性控制)1.private、public、protected關鍵字2.關鍵字示例1、關鍵字對類數據成員訪問的限制3. 公有繼承4. 私有繼承5. 保護繼承6. 私有繼承和保護繼承的區別二、抽象類與純虛函數1.什么是抽象類2.抽象函數/純虛函數3.抽象類示例一、訪問控制 (可見性控制)…

mongodb 如何刪除 字段值為 json對象中的某個字段值

例如&#xff1a; { attributes: { birthday:1988-01-01, name: aq } } birthday是attributes字段的value的一個字段&#xff0c; 我要刪除birthday 用這句話&#xff1a; db.User.update({email:adminlinkris.com},{$unset:{attributes.birthday:}})轉載于:https://www.cnblog…

使用 Spring 的 Web 服務模擬器框架解決方案

http://www.ibm.com/developerworks/cn/web/wa-aj-simulator/index.html轉載于:https://www.cnblogs.com/diyunpeng/archive/2012/02/28/2371390.html

三、上傳織物圖片至SQL Server并提供name進行展示織物照片

一、數據庫的建立 還是在fiber_yy數據庫下創建images表 images表設計如下 二、頁面完善設計 main_page頁面進行功能完善 入庫管理系統 warehousing頁面 庫存查詢系統 query頁面 登錄注冊頁面前面幾個博文已經實現過了&#xff0c;這里就再贅述了&#xff0c;仍是沿用前…

gettype_PHP gettype()函數與示例

gettypePHP gettype()函數 (PHP gettype() function) In PHP, we have a library function gettype() to identify the type of data. The function is primarily used to sanity check the type of data being input in a variable. The function can identify the data into …

ARM MMU工作原理剖析[轉]

一、MMU的產生 許多年以前&#xff0c;當人們還在使用DOS或是更古老的操作系統的時候&#xff0c;計算機的內存還非常小&#xff0c;一般都是以K為單位進行計算&#xff0c;相應的&#xff0c;當時的程序規模也不大&#xff0c;所以內存容量雖然小&#xff0c;但還是可以容納當…

棧與隊列在SGI STL的底層實現

棧 棧提供push和pop等接口&#xff0c;不提供走訪功能&#xff0c;也不提供迭代器。 STL中棧不被歸類為容器&#xff0c;而被歸類為container adapter(容器適配器)&#xff0c;這是因為棧是以底層容器完成其所有的工作&#xff0c;對外提供統一的接口&#xff0c;底層容器是可…