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);
    		
    	}
    
  • 相关阅读:
    linux定时器
    TIMESTAMP和DATETIME的区别
    Linux进程或线程绑定到CPU
    C++学习笔记
    磁盘扇区校验和
    docker安装mysql,并配置部分表同步
    docker 安装tomcat
    多tomcat 同一个浏览器 多个项目 会导致session覆盖
    Ubuntu 安装 NodeJS
    Ubuntu 下安装 Arduino IDE
  • 原文地址:https://www.cnblogs.com/lbloveab/p/7247303.html
Copyright © 2011-2022 走看看