我在尝试配置弹簧控制器时收到此错误。我确定我的名称正确匹配,但它仍然给我这个错误。这是我的控制器类。输入和输出页面也相同。请帮我
“ Bean 名称 'userForm' 的 BindingResult 和普通目标对象都不能用作请求属性”
@Controller
@SessionAttributes
public class UserController {
protected Log logger = LogFactory.getLog(getClass());
@Autowired
UserService userService;
@RequestMapping(value="/userList")
public ModelAndView getUserList(){
List<User> userList = userService.getUserList();
return new ModelAndView("userList", "userList", userList);
}
@RequestMapping(value="/findUser")
public ModelAndView findUser(@ModelAttribute("user") User user,
BindingResult result){
List<User> userResultsList = null;
//model.addAttribute("user", new User());
userResultsList = userService.findUser(user.getUsername(), user.getFirstname(),
user.getLastname());
return new ModelAndView("userList", "user", userResultsList);
}
}
我的 JSP 在这里
<body>
<form:form modelAttribute="user" method="post" action="/findUser.html">
<table>
<tr>
<td><form:label path="username">User ID:</form:label></td>
<td><form:input path="username" /></td>
</tr>
<tr>
<td><form:label path="firstname">First Name</form:label></td>
<td><form:input path="firstname" /></td>
</tr>
<tr>
<td><form:label path="lastname">Last Name:</form:label></td>
<td><form:input path="lastname" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="findUser" /></td>
</tr>
</table>
</form:form>
<table>
<tr>
<td>User Id</td>
<td>First Name</td>
<td>Last Name</td>
<td>Email Address</td>
<td>Last Update Date</td>
<td>Last Update By</td>
</tr>
<c:forEach var="list" items="${userList}">
<tr>
<td>${list.userId}</td>
<td>${list.username}</td>
<td>${list.firstname}</td>
<td>${list.lastname}</td>
<td>${list.email}</td>
<td>${list.lastUpdatedBy}</td>
<td>${list.lastUpdatedDate}</td>
<td><a href="listVendors.html?userId=${list.userId}">assignVendor</a></td>
</tr>
</c:forEach>
</table>