POST请求和控制器中的

POST请求和控制器中的

本文介绍了jsp POST请求和控制器中的@RequestParam给出了HTTP 400语法上错误的错误:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在jsp文件中有一个发布请求:

I have a post request in a jsp file:

<form method="post" action="http://localhost:8081/MerchantMovieTheater/api/movieTheater">
    <input type="hidden" name="balance" id="balance" value="${balance}"/>
    <input type="submit" value="Merchant Site">
</form>

相应的控制器是:

@RequestMapping(value = "movieTheater", method = RequestMethod.POST)
    public String submitTransaction(Model model, @RequestParam("balance") Double balance){
}

但是当我执行jsp时,出现以下错误:

But when I am executing the jsp, I am getting the following error:

HTTP Status 400:  The request sent by the client was syntactically incorrect (Required Double parameter 'balance' is not present).

您能指出我哪里出问题了吗?预先感谢!

Can you please point out to me where I am going wrong?Thanks in advance!

推荐答案

我解决了!我想念一个'?'在网址末尾.该操作应为:

I got it solved! I was missing a '?' at the end of the url. The action should be:

action="http://localhost:8081/MerchantMovieTheater/api/movieTheater?">

现在一切正常!

这篇关于jsp POST请求和控制器中的@RequestParam给出了HTTP 400语法上错误的错误:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 06:16