我有一个有一些价值观的表格。当我提交表单时,我希望当前登录用户的用户ID在路径中传递,以在我的控制器中调用休息服务处理程序。我不知道在形式动作中写什么来实现它。
@RequestMapping(value="/redemptionRedirect1/{userId}", method=RequestMethod.GET)
public @ResponseBody Transaction submitRedemption(@PathVariable("userId") long userId ,@ModelAttribute("redemption") Transaction transaction)
{
boolean flag;
Authentication auth =SecurityContextHolder.getContext().getAuthentication();
String name = auth.getName();
User user=userService.getUser(name);
transaction.setUser(user);
flag = transactionService.addRedemptionTransactions(transaction);
return transaction;
}
>
<body>
<form id="account" action="redemptionRedirect1/${user.userId}" method="get">
<table>
<tr><td>Amount: </td><td><input type="text" maxlength="5" value='<c:out value="${amount}"/>' readonly="readonly"/></td></tr>
<tr><td>
Bank Accounts: </td><td><select id="bankaccounts">
<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 type="text" placeholder='<c:out value="${daccount.dematName}"/>' value='<c:out value="${daccount.dematAccountNumber}"/>' readonly="readonly"/></td></tr>
<tr><td><input type="submit" value="Confirm"/></td></tr>
</table>
<div style="visibility: hidden;"><input id="user" type="text" value='<c:out value="${user.userId}"/>'/></div>
<div id="personFormResponse"></div>
</form>
</body>