Reputation: 17
I am trying to send some values from a form to a responsebody for doing some actions on those values. But the values are not at all getting forwarded to that handler. i couldn't find a reason. What could be the problem here?
My handler
@RequestMapping(value="/redemptionRedirect1/{userId}", method=RequestMethod.GET) @ResponseBody public Transaction submitRedemption(@PathVariable("userId") long userId,@RequestParam(value="amount") String amount1,@RequestParam("bankaccount") int bankaccount,@RequestParam("demataccount") int demataccount) { boolean flag; Double amount=Double.parseDouble(amount1); Transaction transaction=new Transaction(); transaction.setBankAccount(transactionService.getBank(bankaccount)); transaction.setDematAccount(transactionService.getDemat(demataccount)); transaction.setTransactionAmount(amount); Authentication auth = SecurityContextHolder.getContext().getAuthentication(); String name = auth.getName(); User user=userService.getUser(name); transaction.setUser(user); flag = transactionService.addRedemptionTransactions(transaction); return transaction; }
My JSP
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="redemptionRedirect1/${user.userId}.htm" method="get">
<table>
<tr><td>Amount: </td><td><input id="amount" type="text" maxlength="5" value='<c:out value="${amount}"/>' placeholder='<c:out value="${amount}"/>'/></td></tr>
<tr><td>
Bank Accounts: </td><td><select id="bankaccount" >
<c:forEach items="${baccounts}" var="account">
<option value='<c:out value="${account.accountNumber}"/>'>
<c:out value="${account.name}"/>
</option>
</c:forEach>
</select>
</td></tr>
<tr><td>Demat Account: </td><td><input id="demataccount" type="text" placeholder='<c:out value="${daccount.dematName}"/>' value='<c:out value="${daccount.dematAccountNumber}"/>'/></td></tr>
<tr><td><input type="submit" value="Confirm"/></td></tr>
</table>
</form>
</body>
</html>
Upvotes: 0
Views: 638
Reputation: 17
The form serializes itself via name attribute of every input.
So first you may run the developer tools feature of your browser and check if the values are added to the request or (this works only for GET requests) check if the values are added to the URL after the submit. If not - add the name attribute for every corresponding input.
Upvotes: 0