上一篇中咱們已經能夠順利添加商品了,通常地,咱們添加完商品以後會跳轉到咱們的查看商品的頁面上…javascript
Contoller拿到數據庫中的數據css
@RequestMapping("/listBrand.do")
public String listBrand(Model model) throws IOException {
List<EbBrand> brandList = ebBrandService.selectBrand();
model.addAttribute("brandList", brandList);
return "item/listbrand";
}
把文件服務器的路徑添加到總配置文件中java
<c:set var="file_path" value="http://localhost:8081/file"/>
<c:forEach items="${brandList}" var="brand">
<tr>
<td>${brand.brandId}</td>
<td>
<%--這裏須要圖片的全路徑,最好咱們把前部分的路徑在配置文件中寫起來--%>
<img id='imgsImgSrc' src="${file_path}${brand.imgs}" height="50" width="50"/></td>
<td>${brand.brandName}</td>
<td class="nwp">${brand.website}</td>
<td class="nwp">${brand.brandDesc}</td>
<td>${brand.brandSort}</td>
<td>
<a href="${path }/shop/item/editbrand.jsp?brandId="${brand.brandId}>編輯</a>
<a href="#" onclick="singleDel(${brand.brandId})">刪除</a>
</td>
</tr>
</c:forEach>
通常地,咱們的品牌名稱是不會輕易變動的,所以咱們在編輯的時候默認不讓它變動。web
咱們有兩種方式讓用戶修改不了數據庫
通常地,咱們都是使用readonly,由於使用disable的話,後臺是獲取不到值的服務器
在更新的時候,注意要把id和咱們的圖片值傳遞過去,好讓它修改markdown
<input type='hidden' id='imgs' name='imgs' value="${brand.imgs }" reg2="^.+$" tip="親!您忘記上傳圖片了。"/>
<input type="hidden" name="brandId" value="${brand.brandId }">
在刪除品牌以前,詢問是否要刪除網絡
function singleDel(brandId){
if(confirm("你確認要刪除該品牌嗎?")){
window.location.href = "${path}/brand/deleteBrand.do?brandId="+brandId;
}
}
有的時候,可能由於咱們的網絡緣由,用戶填寫完表單的時候,可能會屢次發送添加品牌的請求,所以咱們能夠使用模態窗口來阻止這種狀況的發生:app
<%--操做請求中--%>
<div id="refundLoadDiv" class="alt" style="display:none">
<div class="t"></div>
<div class="c set">
<ul class="uls">
<li style="text-align:center;">
<img src="<c:url value='/ecps/console/res/imgs/loading.gif'/>" />操做請求中... ...
</li>
</ul>
</div>
<div class="f"></div>
</div>
function tipShow(idName){
var idObj = $(idName);
var idBgObj = $("#bgWindow");
if(idBgObj.length == 0){
var iframe,div;
div = $("<div></div>");
div.attr({id:"bgWindow",style:"display:none"});
iframe = $("<iframe></iframe>");
iframe.attr({id:"bgWindowIframe",src:"about:blank",marginwidth:"0",marginheight:"0",frameBorder:"no",framespacing:"0",allowtransparency:"true"});
div.append(iframe);
$(document.body).append(div);
idBgObj = $("#bgWindow");
}
var winH = $(window).height();
var docH = $(document.body).height();
if(winH > docH){docH = winH;}
var winW = $(window).width();
var docW = $(document.body).width();
if(winW > docW){docW = winW;}
var scrollH = $(document).scrollTop();
if(scrollH == undefined){scrollH = 0}
//alert(idObj.height());
var t = parseInt((winH - idObj.height())/2);
if(idObj.css("position") == "absolute"){t = t + scrollH;}
if(t != parseInt(idObj.css("top"))){idObj.css("top",t);}
var l = parseInt((winW - idObj.width())/2);
if(l < 0){l = 0;}
if(l != parseInt(idObj.css("left"))){idObj.css("left",l);}
if(docW != parseInt(idBgObj.css("width"))){idBgObj.css("width",docW);}
if(docH != parseInt(idBgObj.css("height"))){idBgObj.css("height",docH);idBgObj.find("iframe").css("height",docH);}
idBgObj.show();
idObj.show();
window.onresize = function(){
if(idObj.css("display") == "block"){tipShow(idName);}
};
window.onscroll = function(){
if(idObj.css("display") == "block"){tipShow(idName);}
};
var close = idName + "Close";
var reset = idName + "Reset";
var ok = idName + "Ok";
if($(close).length == 1){$(close).click(function(){tipHide(idName);});}
if($(reset).length == 1){$(reset).click(function(){tipHide(idName);});}
if($(ok).length == 1){$(ok).click(function(){tipHide(idName);});}
}
若是校驗沒有問題,那麼就彈出模態窗口jsp
if(isSubmit) {
showTip("#refundLoadDiv");
}