2

我在 spring ajax 调用中遇到错误。我知道这是一些语法错误,但找不到是什么。有人可以帮忙吗?

脚本:

$.ajax({
        type : 'POST',
        contentType : 'application/json; charset=utf-8',
        url: 'saveCommittedAmount.html?investmentId='+investmentId+ '&=transactionData' +transactionData + '&=investorId' +investorId + '&committedAmt='+committedAmt,
        success: function(response) {
            return false;
        }
    });

弹簧控制器:

@RequestMapping(value = "/saveCommittedAmount", method = RequestMethod.POST)
    @ResponseBody
    public String saveInvestmentValue(@RequestParam("investmentId") String investmentId,
            @RequestParam("transactionDate") String transactionDate,@RequestParam("investorId") String investorId,
            @RequestParam("committedAmt") String committedAmt) throws ParseException {
        Transaction transaction = new Transaction();

        Date tDate = (Date) new SimpleDateFormat("MM/dd/yyyy").parse(transactionDate.trim());

        transaction.setCommittedAmount(BigDecimal.valueOf(Double.valueOf(committedAmt)));
        transaction.setUserId(Integer.parseInt(investorId));
        System.out.println("committedAmt" + "committedAmt");
        transaction.setTransActDate(tDate);
        transaction.setInvestmentId(Integer.parseInt(investmentId));
        assetService.updateTransaction(transaction);
        return Constants.RESPONSE_SUCCESS;
    }
4

1 回答 1

2

您的saveInvestmentValue方法需要一个@RequestParam("transactionDate").

但是,您的 ajax 调用发送transactionData. 您应该将其更改为相同

 url: 'saveCommittedAmount.html?investmentId='+investmentId+ '&=transactionDate' +transactionDate + '&=investorId' +investorId + '&committedAmt='+committedAmt,
于 2013-08-02T10:33:57.500 回答