我有一个控制器
@RequestMapping(value = "/admin/manage/{id}", method = RequestMethod.GET)
public ModelAndView goManage(@PathVariable int id) {
UserAccount userAccount = userAccountService.findUserAccount(id);
ModelAndView mav = new ModelAndView("admin/manage");
mav.addObject("userAccount", userAccount);
return mav;
}
我将userAccount模型传递给manage.jsp视图。在视图中我显示此模型。例如:
<div id="info">
<label>Login:</label><label>${userAccount.userDto.username}</label><br />
<label>Name:</label><label>${userAccount.userDto.firstName}
${userAccount.userDto.lastName}</label>
</div>
<form:form
action="${pageContext.request.contextPath}/admin/go"
modelAttribute="userAccount" method="post">
<input class="myButton" type="submit" value="Go" />
</form:form>
没关系,但是当我点击按钮Go时,我希望将此模型的userAccount从视图传递到下一个控制器。我上面的表单实现不起作用。我如何从视图传递对象?有可能吗?
@RequestMapping(value = "/admin/go", method = RequestMethod.POST)
public ModelAndView goWithDrawalInvestment(
@ModelAttribute("userAccount") UserAccount userAccount) {
userAccount.setBalance(0);
mav.addObject("userAccount", userAccountDto);
return mav;
}