• 对某个商品的上下架状态进行改变


    状态这个字段在数据表中,属于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);
    		
    	}
    
  • 相关阅读:
    shell进行mysql统计
    java I/O总结
    Hbase源码分析:Hbase UI中Requests Per Second的具体含义
    ASP.NET Session State Overview
    What is an ISAPI Extension?
    innerxml and outerxml
    postman
    FileZilla文件下载的目录
    how to use webpart container in kentico
    Consider using EXISTS instead of IN
  • 原文地址:https://www.cnblogs.com/lbloveab/p/7247303.html
Copyright © 2020-2023  润新知