'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"));


});


Solution 1:[1]

From the exception, your problem likely occurs because the @RequestMapping doesn't find the parameter being sent from previous the page.

In this case, it is likely like this:

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

From here, the exception occurs when the @RequestMapping doesn't find "params":

@RequestParam(value = "params") String params

This happens because, by default, @RequestParam tries to get the value. It then returns an exception when the value is not found.

So you have two ways to resolve this,

  1. You can supply the URL /check with a 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 an example to reflect your scenario and problem. Gud luk.

Solution 2:[2]

I had the same error message. My mistake was that I wrote on Javascript side:

MyService.getStatus(vm.id);

instead of:

MyService.getStatus({id : vm.id});

so the parameter was not named as expected on Java side:

@GetMapping("/myservice/getStatus")
@Timed
public ResponseEntity<String> getStatus(@RequestParam("id") Long id) {

Solution 3:[3]

It was fixed by adding required = false like this:

Before adding:

public String saveOrUpdate(
    @RequestParam("studentId") String studentId,
    @RequestParam("name") String name) {

After adding:

public String saveOrUpdate(
        @RequestParam(value = "studentId", required = false) String studentId,
        @RequestParam("name") String name) {

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 J. Chan
Solution 2 RotS
Solution 3 Laurel