异常:org.springframework.web.bind.MissingServletRequestParameterException:所需的字符串参数“params"不存在 [英] Exception: org.springframework.web.bind.MissingServletRequestParameterException: Required String parameter 'params' is not present

查看:26
本文介绍了异常:org.springframework.web.bind.MissingServletRequestParameterException:所需的字符串参数“params"不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我单击编辑按钮时,dataTable 中的值应显示在表单中.但不知何故它不起作用.以下是我的代码供参考.

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.

调用数据表:

$("#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"));


});

推荐答案

从异常来看,您的问题很可能是因为 @RequestMapping 没有找到从前一页发送的参数.

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
}

从这里开始,当 @RequestMapping 没有找到 params" 时会发生异常:

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

@RequestParam(value = "params") String params

发生这种情况是因为默认情况下,@RequestParam 会尝试获取该值.然后在找不到该值时返回异常.

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. 您可以提供带有 params 变量的 URL /check 或者,

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

您可以像这样将 @RequestParam 要求更改为 false:

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

@RequestParam(value = "params", required = false) 字符串参数

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

请注意,这是一个反映您的场景和问题的示例.古德卢克.

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

这篇关于异常:org.springframework.web.bind.MissingServletRequestParameterException:所需的字符串参数“params"不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆