zhh1996075 2016-09-14 07:47 采纳率: 0%
浏览 1933
已采纳

这个Controller控制器怎么写

    /**
     * 费用管理修改
     * @throws Exception 
     */
   @ResponseBody
   @RequestMapping(value="/updateCharingCost")
   public boolean updateCharingCost(ChargingCost chargingCost) throws Exception {
        User usr = (User) this.getSession().getAttribute(Const.SESSION_USER);
        String usrID = usr.getUserID();
        boolean bool=false; 
                bool=chargingCostService.update(chargingCost, usrID);                   
        return bool;         
    }
   /**
    * 费用管理删除
 * @throws Exception 
    */
   @ResponseBody
   @RequestMapping(value="/deleteCharingCost")
   public boolean deleteChargingCost(ChargingCost chargingCost) throws Exception{
        User usr = (User) this.getSession().getAttribute(Const.SESSION_USER);
        String usrID = usr.getUserID();
       boolean bool=chargingCostService.delete(chargingCost, usrID);
       return bool;
   }
}
这个是Controller,,

    public boolean update(ChargingCost chargingCost, String usrID) throws Exception {
    boolean bool = false;
    Date date = Tools.getNowtimeTwo();
    chargingCost.setUpdateUser(usrID);
    chargingCost.setUpdateDTTM(date);
    int ExecuteCnt = (int) this.getDaoSupport().update("ChargingCost.update", chargingCost);
    if (ExecuteCnt > 0) {
        bool = true;
    }
    return bool;
}

/**
 * 删除费用
 */
public boolean delete(ChargingCost chargingCost, String usrID) throws Exception {
    boolean bool = false;
    Date date = Tools.getNowtimeTwo();
    chargingCost.setDeleteFlag(0);
    chargingCost.setUpdateUser(usrID);
    chargingCost.setUpdateDTTM(date);
    int ExecuteCnt = (int) this.getDaoSupport().update("ChargingCost.delete", chargingCost);
    if (ExecuteCnt > 0) {
        bool = true;
    }
    return bool;
}
这个是service,

function update_Cost() {
var len = document.getElementsByName("chk").length;
var selectCount = 0; // 判断是否一个未选
for (var i = 0; i < len; i++) {
    if (document.getElementsByName("chk")[i].checked == true) {
        selectCount = selectCount + 1;
        userData.push(i + 1);
        s=i+1;
    }
}
if (selectCount == 1) {
    $('#costInformationUpdate').modal('show');
    // 设置弹出窗口的位置
    var model=document.getElementById("costInformationUpdate");
    var tb = document.getElementById("costTable");
    var tr = tb.rows[s];
    $("#updateChargingStationName").val(tr.cells[2].innerText);
    $("#updateEffectiveDate").val(tr.cells[3].innerText);
} else if (selectCount == 0) {
    showMessge("请选择要操作的数据!","model1");
} else {
    showMessge("抱歉,不能选择多行!","model1");
}

}
//确认修改
function updateChargingCost(){
var updateChargePrice=$("#updateChargePrice").val();
var updateServicePrice=$("#updateServicePrice").val();
var updateMonthKWH=$("#updateMonthKWH").val();
$.ajax({
type: "POST",
url: 'updateCharingCost',
data: {
ChargePrice:updateChargePrice,
ServicePrice:updateServicePrice,
MonthKWH:updateMonthKWH,
},
dataType:'json',
success : function(data) {
if (data) {
showMessge("修改成功!","model1");
$('#update').modal('hide');
saveCharingCost();
} else {
showMessge("修改失败!","model1");
$('#update').modal('hide');
}
},
error : function(data) {
if (data.status == "403" && data.statusText == "Forbidden") {
showMessge("您没有操作权限!","model1");
} else {
showMessge("操作失败!","model1");
}
}
});
}
这个是js,,但是date一直是false,觉得是控制器写错了,,大神告诉我怎么写吧,没有一点思路

  • 写回答

3条回答 默认 最新

  • cr135810 2016-09-14 10:16
    关注

    自己在逐步排查一下把,应该很简单的问题。看看方法执行成功没,打断点调一下,全搞定了就行

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 matlab有关常微分方程的问题求解决
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable