jsp страничка
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<c:set var="contextPath" value="${pageContext.request.contextPath}"/>
<html>
<head>
<title></title>
</head>
<body>
<form:form method="POST" modelAttribute="selectForm" class = "form-control">
<div class="container">
<form:select path="${login}" name="login" class = "form-control">
<form:option value="NONE" label="--- Select ---" />
<form:options items="${usersList}" itemValue="login"/>
</form:select>
</div>
<input class="btn-default btn btn1" type="submit" name="submit" value="Submit">
</form:form>
</body>
</html>
контроллер
@Controller
public class WaiterController{
@Autowired
private UserService userService;
@RequestMapping(value = {"waiter"}, method = RequestMethod.GET)
public String waiter (Model model) {
model.addAttribute("selectForm", userService.findAll());
initModelList(model);
return "waiter";
}
@RequestMapping(value = "/waiter", method = RequestMethod.POST)
public String waiter(@RequestParam("login") String login, Model model){
model.addAttribute("selectForm", userService.findByLogin(login));
initModelList(model);
return "waiter";
}
private void initModelList(Model model) {
List<User> usersList = userService.findAll();
List<String> usersLoginList = new ArrayList<String>();
for (User user : usersList) {
usersLoginList.add(user.getLogin());
}
model.addAttribute("usersList", usersLoginList);
}
}
User class
@Entity
@Table(name = "users")
public class User {
public enum Role {
ROLE_USER, ROLE_ADMIN
}
@Id
@GeneratedValue (strategy = GenerationType.AUTO)
@Column(name = "user_id")
private long id;
@Column(name = "firstname")
private String firstName;
@Column(name = "lastname")
private String lastName;
@Column(name = "login")
private String login;
@Column(name = "password")
private String passwordHash;
@Column(name = "role")
private Role role;
@OneToMany (mappedBy = "user", cascade = CascadeType.ALL)
private Set<TableC> tableCSet;
public User() {
}
public long getID() {
return id;
}
public void setID(long id) {
this.id = id;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getLogin() {
return login;
}
public void setLogin(String login) {
this.login = login;
}
public String getPasswordHash() {
return passwordHash;
}
public void setPasswordHash(String passwordHash) {
this.passwordHash = passwordHash;
}
public Role getRole() {
return role;
}
public void setRole(Role role) {
this.role = role;
}
public Set<TableC> getTableCSet() {
return tableCSet;
}
public void setTableCSet(Set<TableC> tableCSet) {
this.tableCSet = tableCSet;
}
}
проблема в том, что form:select path="" не задается