Vanan Vanan - 6 months ago 46
Javascript Question

Exception: org.springframework.web.bind.MissingServletRequestParameterException: Required String parameter 'params' is not present

When i clicked the edit button the values from dataTable should display in form. But somehow it doesn't work. Below are my codes for reference.

Call DataTable:

$("#tranTable").on("click", "#edit", function(){
var row = $(this).closest("tr");

$("#Own-Account").removeClass("hidden");
$("fieldset#addToListMethod").addClass("hidden");
$("fieldset#Own-Account #templateTrxId").val( row.find("[name$=templateTrxId]").val() )
$("fieldset#Own-Account #templateId") .val( row.find("[name$=templateId]").val() )
$("fieldset#newFT #fromAccNo") .val( row.find("[name$=fromAccNo]").val() ),
$("fieldset#newFT #methodOfTransfer") .val( row.find("[name$=methodOfTransfer]").val() ),
$("fieldset#Own-Account #toAccNo") .val( row.find("[name$=toAccNo]").val() ),
$("fieldset#Own-Account #paymentRef") .val( row.find("[name$=paymentRef]").val() ),
$("fieldset#Own-Account #amount") .val( row.find("[name$=amount]").val() ),

//hidden
$("fieldset#Own-Account #otherPaymentDetail").val( row.find("[name$=otherPaymentDetail]").val() ),
$("fieldset#Own-Account #email1").val( row.find("[name$=email1]").val() ),
$("fieldset#Own-Account #email2").val( row.find("[name$=email2]").val() ),
$("fieldset#Own-Account #sms1").val( row.find("[name$=sms1]").val() ),
$("fieldset#Own-Account #sms2").val( row.find("[name$=sms2]").val() ),
$("fieldset#Own-Account #purpose").val( row.find("[name$=purpose]").val() )
$("fieldset#Own-Account #isEdit").val(1);
$("fieldset#Own-Account #dataTableRowId").val(row.data("row-id"));


});

Answer

From the exception,your problem are likely to be found because the @RequestMapping doesn't found the parameter being send from previous page.

In this case is likely like this:

@RequestMapping(value = "/check")
public String getID(@RequestParam(value = "params") String params){
//your logic code here
}

From here,the exception come when the @RequestMapping doesnt found "params":

@RequestParam(value = "params") String params

This happen because by default @RequestParam will try to get the value and return an exception when the value was not found.

So you have two ways to resolve this,

1) You can supply the URL /check with params variable or,

2) You can change the @RequestParam requirement to false like this:

@RequestParam(value = "params", required = false) String params

Take note that this is example to reflect your scenario and problem. Gud luk.