新巴巴運動網 項目第三天
-
今天內容
-
Dubbo優化
-
搭建后台管理頁面
-
品牌管理 列表查詢(帶條件 + 分頁)
-
品牌管理 去修改頁面
-
品牌管理 異步上傳圖片
-
Dubbo優化
-
-
超時
-
服務消費方通過注冊中心獲取服務提供方的地址、調用服務提供方、由於服務提供方可能已經宕機、不能提供服務
-
服務消費方在1秒內沒有得到回應、為了給用戶提供非常服務、馬上與服務提供方斷開連接、再向注冊中心獲取新的服務提供方的地址、調用新的服務提供方
-
Dubbo用此方法來完成分布式情況下、服務器出現故障、而不影響用戶的訪問
-
直接連接
服務提供方地址
192.168.79.100:20880
正確
127.0.0.1:20880
服務消費方直接連接
-
服務消費方不檢查 服務提供方
-
搭建后台管理頁面
-
頁面原型位置
-
Springmvc配置
-
入口頁面
/WEB-INF/console/index.jsp
-
跳轉入口頁面的程序
在CenterController中
-
商品模塊入口
-
商品模塊入口路徑設置
-
top.jsp中
-
CenterController中
-
POST提交(亂碼)
-
統一處理空串及空串串
去掉前后空格、
例如:
頁面上傳遞的參數前面或后面都有空串,需要去掉
頁面上傳遞的參數為空串時,也需要轉成Null
-
配置Conveter轉換器的工廠
Springmvc中配置
-
自定義類(轉換的類)
-
品牌管理之列表查詢
-
品牌表
-
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');
-
品牌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
-
查詢列表
-
需求說明
-
點擊品牌管理 –>右側跳轉到品牌列表頁面 無條件
-
點擊查詢按鈕 —>刷新品牌列表頁面 條件:品牌名稱 是否可見
-
點擊分頁頁號 à加載相應頁面的數據 帶上查詢條件
-
品牌管理入口的路徑
-
/brand/list.do
入參 : 無 (默認 是(可見))
-
Dao
入參:BrandQuery 對象
返回值:結果集 品牌
-
Mapper
-
BrandService
入參:品牌名稱 是否可見
返回值:結果集 品牌
-
BrandController
入參: 品牌名稱 是否可見
返回值:結果集 品牌
跳轉視圖 brand/list
-
頁面
回顯數據
-
回顯查詢條件
-
品牌管理之列表查詢(分頁)
分頁源碼
-
BrandQuery
-
Dao
-
Mapper
-
BrandService
入參:當前頁 名稱 是否可用
返回值:分頁對象 (里面有品牌結果集)
-
BrandController
入參:當前頁 名稱 是否可用
返回值:分頁對象 (里面有品牌結果集)
跳轉視圖 不變
-
頁面遍歷分頁對象
-
頁面 分頁 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>
-
Get請求亂碼
Server.xml
-
品牌管理之修改
-
去修改頁面
-
設置路徑
/brand/toEdit.do?id=${brand.id}
-
Dao
-
Mapper
-
Service
-
Controller
-
頁面回顯
-
上傳圖片
-
保存圖片的位置
-
-
頁面
-
Springmvc 配置支持上傳圖片
-
UploadController 接收圖片