jsp POST request and @RequestParam in controller g

2019-09-12 23:35发布

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> 

The corresponding controller is:

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

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!

标签: java jsp rest post
1条回答
放荡不羁爱自由
2楼-- · 2019-09-13 00:11

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?">

Now everything is working fine!

查看更多
登录 后发表回答