zoukankan      html  css  js  c++  java
  • 对某个商品的上下架状态进行改变

    状态这个字段在数据表中,属于tinyInt类型,转换到数据库中是bit类型,只有0和1,转换完是true和false

    在jsp页面上,编写JS

    function update(id,saleState) {
    	    if(saleState==false){
    			confirm("您确定要上架吗?");
    			window.location.href="goodsDetail_update1.action?goodsdetail.id="+id;
    	    }else{
    	        confirm("您确定要下架吗?");
    			window.location.href="goodsDetail_update1.action?goodsdetail.id="+id;
    	    };
    	 };
    
    <a class="button border-main" href="javascript:void(0)" onclick="update(${goodsdetail.id},${goodsdetail.saleState})">
                            <span class="icon-edit"></span>
                            <c:if test="${goodsdetail.saleState==false }">上架</c:if>
                            <c:if test="${goodsdetail.saleState==true  }">下架</c:if>
                            </a>
    

     编写action方法

    public String update1(){
    		Integer id=goodsdetail.getId();
    		goodsdetail=goodsDetailService.find(id);
    		if(goodsdetail.getSaleState()){
    			goodsdetail.setSaleState(false);
    		}else{
    			goodsdetail.setSaleState(true);
    		}
    		goodsDetailService.update(goodsdetail);
    		return "eee";
    	}
    

     dao实现类的方法

    @Override
    	public void update1(Goodsdetail goodsdetail) {
    		hibernateTemplate.update(goodsdetail);
    		
    	}
    
  • 相关阅读:
    抽象类abstract
    final关键字特点
    继承ExtendsFour
    继承(继承中构造方法的关系)
    继承ExtendsTwo-super&this
    继承ExtendsOne
    静态
    构造方法与setXxx方法
    15.8
    15.7
  • 原文地址:https://www.cnblogs.com/lbloveab/p/7247303.html
Copyright © 2011-2022 走看看