新巴巴運動網 項目第三天


新巴巴運動網 項目第三天

 

 

  1. 今天內容

  1. Dubbo優化
  2. 搭建后台管理頁面
  3. 品牌管理 列表查詢(帶條件 + 分頁)
  4. 品牌管理 去修改頁面
  5. 品牌管理 異步上傳圖片
    1. Dubbo優化

 

  1. 超時

 

 

 

 

 

 

  1. 服務消費方通過注冊中心獲取服務提供方的地址、調用服務提供方、由於服務提供方可能已經宕機、不能提供服務
  2. 服務消費方在1秒內沒有得到回應、為了給用戶提供非常服務、馬上與服務提供方斷開連接、再向注冊中心獲取新的服務提供方的地址、調用新的服務提供方
  3. Dubbo用此方法來完成分布式情況下、服務器出現故障、而不影響用戶的訪問

 

 

 

 

 

  1. 直接連接

 

 

服務提供方地址

192.168.79.100:20880

正確

127.0.0.1:20880

 

服務消費方直接連接

 

 

 

  1. 服務消費方不檢查 服務提供方

 

 

 

 

 

  1. 搭建后台管理頁面

  1. 頁面原型位置

 

 

  1. Springmvc配置

 

  1. 入口頁面

/WEB-INF/console/index.jsp

 

  1. 跳轉入口頁面的程序

在CenterController中

 

  1. 商品模塊入口

  1. 商品模塊入口路徑設置

  1. top.jsp中

 

  1. CenterController中

  1. POST提交(亂碼)

  1. 統一處理空串及空串串

去掉前后空格、

例如:

頁面上傳遞的參數前面或后面都有空串,需要去掉

頁面上傳遞的參數為空串時,也需要轉成Null

  1. 配置Conveter轉換器的工廠

Springmvc中配置

  1. 自定義類(轉換的類)

 

 

  1. 品牌管理之列表查詢

    1. 品牌表

DROP TABLE IF EXISTS `bbs_brand`;

CREATE TABLE `bbs_brand` (

`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',

`name` varchar(40) NOT NULL COMMENT '名稱',

`description` varchar(80) DEFAULT NULL COMMENT '描述',

`img_url` varchar(80) DEFAULT NULL COMMENT '圖片Url',

`web_site` varchar(80) DEFAULT NULL COMMENT '品牌網址',

`sort` int(11) DEFAULT NULL COMMENT '排序:最大最排前',

`is_display` tinyint(1) DEFAULT NULL COMMENT '是否可見 1:可見 0:不可見',

PRIMARY KEY (`id`)

) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8 COMMENT='品牌';

 

 

 

Int 10億

Bigint 10億億

Tingint -128~127

INSERT INTO bbs_brand VALUES ('1', '依琦蓮', null, null, null, '99', '1');

INSERT INTO bbs_brand VALUES ('2', '凱速(KANSOON', null, null, null, 98, '1');

INSERT INTO bbs_brand VALUES ('3', '梵歌納(vangona', null, null, null, 97, '1');

INSERT INTO bbs_brand VALUES ('4', '伊朵蓮', null, null, null, 96, '1');

INSERT INTO bbs_brand VALUES ('5', '菩媞', null, null, null, 95, '1');

INSERT INTO bbs_brand VALUES ('6', '丹璐斯', null, null, null, 94, '1');

INSERT INTO bbs_brand VALUES ('7', '喜悅瑜伽', null, null, null, 93, '1');

INSERT INTO bbs_brand VALUES ('8', '皮爾(pieryoga', null, null, null, 92, '1');

INSERT INTO bbs_brand VALUES ('9', '路伊梵(LEFAN', null, null, null, 91, '1');

INSERT INTO bbs_brand VALUES ('10', '金啦啦', null, null, null, 90, '0');

INSERT INTO bbs_brand VALUES ('11', '來爾瑜伽(LaiErYoGA', null, null, null, 89, '1');

INSERT INTO bbs_brand VALUES ('12', '艾米達(aimida', null, null, null, 88, '1');

INSERT INTO bbs_brand VALUES ('13', '斯泊恩', null, null, null, 87, '1');

INSERT INTO bbs_brand VALUES ('14', '康愫雅KSUA', null, null, null, 86, '1');

INSERT INTO bbs_brand VALUES ('15', '格寧', null, null, null, 85, '1');

INSERT INTO bbs_brand VALUES ('16', 'E奈爾(Enaier', null, null, null, 84, '1');

INSERT INTO bbs_brand VALUES ('17', '哈他', null, null, null, 83, '1');

INSERT INTO bbs_brand VALUES ('18', '伽美斯(Jamars', null, null, null, 82, '1');

INSERT INTO bbs_brand VALUES ('19', '瑜伽樹(yogatree', null, null, null, 81, '1');

INSERT INTO bbs_brand VALUES ('20', '蘭博伊人(lanboyiren', null, null, null, 80, '1');

 

 

 

 

  1. 品牌POJO

/**

* 品牌

* @author lx

*

*/

public class Brand implements Serializable{

 

    /**

     * 默認的ID

     */

    private static final long serialVersionUID = 1L;

    

    //品牌ID bigint

    private Long id;

    //品牌名稱

    private String name;

    //描述

    private String description;

    //圖片URL

    private String imgUrl;

    //排序 越大越靠前

    private Integer sort;

    //是否可用 0 不可用 1 可用

    private Integer isDisplay;//is_display

 

  1. 查詢列表

 

  1. 需求說明

  1. 點擊品牌管理 –>右側跳轉到品牌列表頁面 無條件
  2. 點擊查詢按鈕 —>刷新品牌列表頁面 條件:品牌名稱 是否可見
  3. 點擊分頁頁號 à加載相應頁面的數據 帶上查詢條件
    1. 品牌管理入口的路徑

/brand/list.do

 

入參 : 無 (默認 是(可見))

 

  1. Dao

入參:BrandQuery 對象

返回值:結果集 品牌

 

 

 

  1. Mapper

  1. BrandService

入參:品牌名稱 是否可見

返回值:結果集 品牌

 

 

 

  1. BrandController

 

入參: 品牌名稱 是否可見

返回值:結果集 品牌

跳轉視圖 brand/list

 

 

 

  1. 頁面

回顯數據

 

 

 

  1. 回顯查詢條件

 

 

 

  1. 品牌管理之列表查詢(分頁)

分頁源碼

  1. BrandQuery

 

  1. Dao

  1. Mapper

 

 

 

  1. BrandService

入參:當前頁 名稱 是否可用

返回值:分頁對象 (里面有品牌結果集)

  1. BrandController

入參:當前頁 名稱 是否可用

返回值:分頁對象 (里面有品牌結果集)

跳轉視圖 不變

 

 

 

  1. 頁面遍歷分頁對象

 

 

 

  1. 頁面 分頁 A標簽

路徑

<a onclick=window.location.href='/brand/list.do?&isDisplay=1&pageNo=2'>2</a>

<a onclick=window.location.href='/brand/list.do?name=依&isDisplay=1&pageNo=2'>2</a>

 

<a onclick=window.location.href='/brand/list.do?name=依&isDisplay=1&pageNo=2'>2</a>

 

<a onclick=window.location.href='/brand/list.do?name=依&isDisplay=1&pageNo=2'>2</a>

 

<a onclick=window.location.href='/brand/list.do?name=依&isDisplay=1&pageNo=2'>2</a>

 

 

 

 

  1. Get請求亂碼

 

 

 

 

Server.xml

 

  1. 品牌管理之修改

    1. 去修改頁面

設置路徑

/brand/toEdit.do?id=${brand.id}

 

 

 

  1. Dao

  1. Mapper

  1. Service

 

  1. Controller

  1. 頁面回顯

 

  1. 上傳圖片

    1. 保存圖片的位置

 

  1. 頁面

 

 

 

 

  1. Springmvc 配置支持上傳圖片

 

 

  1. UploadController 接收圖片

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

      

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM