我正在尝试将一些值从表单发送到响应主体,以便对这些值执行某些操作。但是这些值根本没有转发到该处理程序。我找不到理由。 这可能是什么问题?
我的处理程序
@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; }
我的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>
答案 0 :(得分:0)
表单通过每个输入的 name 属性自行序列化 因此,首先您可以运行浏览器的开发人员工具功能,并检查值是否已添加到请求中(或仅适用于GET请求)检查提交后是否将值添加到URL。如果不是 - 为每个相应的输入添加name属性。