Spring MVC - RequestParamException parameter is not present

前端 未结 3 1948
情话喂你
情话喂你 2021-02-13 11:21

I\'ve got an issue that occurs eventually in my website. It uses AJAX requests to get data from the server, which uses Spring MVC.

What

相关标签:
3条回答
  • 2021-02-13 11:56

    If you are not been able to figure out what is reason behind missing parameter, so you can add

    public void controllerMethodName (@RequestParam(required = false) int page)
    

    code in your controller definition which will not throw any exception if parameter is not present in your ajax request.

    0 讨论(0)
  • 2021-02-13 12:04

    Make the below change to controller's class method for page parameter @RequestParam(defaultValue = 0) int page.

    Or paste the controller method here.

    0 讨论(0)
  • 2021-02-13 12:06

    Are you sure your form isn't being modified at the same time? For example, if your library used to handle the scrolling of the page tries to send the same form in a very short time (the first call updates the form while the second call is serializing it). This might be only on some browsers, not all of them, given that you can't easily reproduce it.

    The way data is put back in the form might also be responsible for your problem.

    Logging HTTP requests / using analytics would help you identify which requests / user agents are causing issues.

    0 讨论(0)
提交回复
热议问题