0

我正在研究 angularjs 和 Spring 框架。我正在尝试将数据库中的数据带入我的表单。t 工作正常。现在,当我再次保存相同的数据而不进行任何修改时...它将空值发送到数据库。我认为模型没有更新,但这与我最初用来将数据带到我的表单中的模型相同。那么,有人可以帮帮我吗?

我的 HTML:

<div class="span12">Contract Duration [?]</div>
<div class="span3" height="20px"></div>
<div class="span4"><input id="duration" type="text"   value={{data1.contractDuration}}
    placeholder="enter duration in years" ng-model="param.contractDuration"
    name="amount" /></div>
</div>
</div>


<div class="landingHeadeLabel row-fluid subdiv2"><label
    class=" subHead">&nbsp;&nbsp;&nbsp;&nbsp;Criteria
for Auto Status Change based on Amendment in CMS</label></div>
<div class="row-fluid supersubDiv2">
<div class="row-fluid marginDiv2">
<div class="span12">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sum of
Amendments [?]</div>
<div class="span3"><select class="select"
    ng-model="param.sumOfAmendmentsCurrency"
    ng-options="curItr for curItr in param.currencyList"><option value="">{{data1.sumOfAmendmentsCurrency}}</option>
</select></div>
<div class="span4"><input id="amendmentsum" type="text"  value={{data1.sumOfAmendments}}
    placeholder="enter value" ng-model="param.sumOfAmendments"
    name="amount" /></div>
<div class="span4" >
<h4 class="note">Note:</br>
Status of FCM Contract for which Contract Value bifurcation is not done
will be changed to Requires Resubmission triggered by Amendment in CMS
contract if below criteria are met on amendment.</h4>
</div>
<div class="span12">
<p>No. of Amendments [?]</p>
</div>

<div class="span4"><input id="amendments" type="text"  value={{data1.numberOfAmendments}}
    placeholder="enter duration" ng-model="param.numberOfAmendments"
    name="amount" /></div>
</div>

</div>
<div align="right" class="finalDiv">
<a href="" ng-click="cancelCntrctDtls()">Cancel</a> <input type="button"
    class="btn saveButton" 
    value="Save Configuration" ng-click="saveCntrctDtls()"></div>
</div>
</div>


@RequestMapping(value = "/savecntrctdtls", method=RequestMethod.POST,produces="application/json")
    public @ResponseBody ParamConfigDtlsDto saveDetails(@RequestBody ParamConfigDtlsDto objParamConfigDto)throws Exception{

        LOG.info("Para Config Controller | Save Details");
        System.out.println(objParamConfigDto);
        ParamConfigDtlsDto validErrorFlag;
        ParamConfigDtlsDto paramConfigDtls=new ParamConfigDtlsDto();
        LOG.debug("Para Config Controller | DTO "+objParamConfigDto);

        LOG.info("ParamConfigSavController| save action invoked ");

        validErrorFlag=paramConfigSaveService.validateParamDetails(objParamConfigDto);

        if(!validErrorFlag.getValidateError())
        {
            paramConfigDtls=paramConfigSaveService.savDetails(objParamConfigDto);

        if(null==objParamConfigDto.getErrorMessage())
            LOG.info("ParamConfigSavController| save action successfull ");
        else
            LOG.info("ParamConfigSavController| save action unsuccessfull | Procedure Error.");
        }

        else
        {
            LOG.info("Validation Error || Please check if all entries are filled and in Proper format");
        }
        return paramConfigDtls;
    }

我的道:

@Override
    public void savDetails(ParamConfigDtlsDto data) throws SQLException{

        JdbcTemplate jdbcTemplate;

        String iouName=data.getIouName();
        jdbcTemplate = new JdbcTemplate(dataSource);

        int iouNameList = jdbcTemplate.queryForInt(SQLQuery.fetchIouId,new Object[]{iouName});
        data.setIouID(iouNameList);


        this.jdbcCall =  new SimpleJdbcCall(dataSource).withProcedureName(DBConstants.FCM_PARA_CONF_INS_PRC);
        jdbcTemplate = new JdbcTemplate(dataSource);

        String userId = (String)SecurityContextHolder.getContext().getAuthentication().getPrincipal();

        Map<String,Object> args=new HashMap<String,Object>(); 
        args.put(DBConstants.PI_IOU_ID,data.getIouID());
        args.put(DBConstants.PI_CONTRACT_VALUE,data.getContractValue());
        args.put(DBConstants.PI_CONTRACT_DURATION,data.getContractDuration());
        args.put(DBConstants.PI_CURRENCY_ID,data.getContractCurrency());
        args.put(DBConstants.PI_DURATION_UNIT,"YEARS");                             /*As per requirement,default value of contract duration is in Years*/
        args.put(DBConstants.PI_AMENDMENT_SUM_AMT,data.getSumOfAmendments());
        args.put(DBConstants.PI_AMENDMENT_COUNT,data.getNumberOfAmendments());
        args.put(DBConstants.PI_AMENDMENT_CURRENCY_ID,data.getSumOfAmendmentsCurrency());
        args.put(DBConstants.PROC_PI_USER_ID,userId);

        Map<String,Object> out=jdbcCall.execute(args); 

        ParamConfigDtlsDto paramConfigDtlsDto=new ParamConfigDtlsDto(); 
        paramConfigDtlsDto.setErrorCode((String)out.get(DBConstants.PO_ERROR_CODE));
        paramConfigDtlsDto.setErrorMessage((String)out.get(DBConstants.PO_ERROR_MSG));


    }
}

用于数据保存的我的客户端脚本:

$http.post('rest/savecntrctdtls',$scope.param).success(function(data){
                $scope.errsuccess=true;

            }).error(function(data){
                alert("error while saving data | Flag returned is");
            }); 
4

0 回答 0