Estou com Seguinte Erro ao Carregar Formulário.
org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: org.springframework.beans.NotReadablePropertyException: Invalid property 'nome' of bean class [java.lang.Class]: Bean property 'nome' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
Segue Class Usuario
@Entity public class Usuario implements UserDetails {
private static final long serialVersionUID = 1L;
@Id
private String nome;
private String email;
private String senha;
private String sumarioPath;
@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(name = "Usuario_Role",
joinColumns = @JoinColumn(name = "email"),
inverseJoinColumns = @JoinColumn(name = "role_nome"))
private List<Role> roles = new ArrayList<>();
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getSenha() {
return senha;
}
public void setSenha(String senha) {
this.senha = senha;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public List<Role> getRoles() {
return roles;
}
public void setRoles(List<Role> roles) {
this.roles = roles;
}
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
return this.roles;
}
@Override
public String getPassword() {
return this.senha;
}
@Override
public String getUsername() {
return this.email;
}
@Override
public boolean isAccountNonExpired() {
return true;
}
@Override
public boolean isAccountNonLocked() {
return true;
}
@Override
public boolean isCredentialsNonExpired() {
return true;
}
@Override
public boolean isEnabled() {
return true;
}
public String getSumarioPath() {
return sumarioPath;
}
public void setSumarioPath(String sumarioPath) {
this.sumarioPath = sumarioPath;
}
}
Segue Div do Formulario .
<div class="container">
<h1>Cadastro de Usuario</h1>
<form:form action="${s:mvcUrl('UC#gravar').build()}" method="post" commandName="usuario" enctype="multipart/form-data">
<div class="form-group">
<label>Nome</label>
<input type="text" name="usuario.nome" cssClass="form-control"/>
<form:errors path="nome" />
</div>
<div class="form-group">
<label>Email</label>
<input type="text" name="email" cssClass="form-control"/>
<form:errors path="usuario.email" />
</div>
<div class="form-group">
<label>Senha</label>
<input type="password" name="senha" cssClass="form-control"/>
<form:errors path="usuario.senha" />
</div>
<button type="submit" class="btn btn-primary">Cadastrar</button>
</form:form>
</div>
Segue Controller.
@Controller @RequestMapping(value="/usuario") public class UsuarioController {
@Autowired
private UsuarioDAO dao;
@Autowired
private FileSaver fileSaver;
@InitBinder
public void initBinder(WebDataBinder binder) {
binder.addValidators(new UsuarioValidation());
}
@RequestMapping("/form")
public ModelAndView form(Usuario usuarios) {
ModelAndView modelAndView = new ModelAndView("form");
modelAndView.addObject("usuario", Usuario.class);
return modelAndView;
}
@RequestMapping(method=RequestMethod.POST)
public ModelAndView gravar(MultipartFile sumario, @Valid Usuario usuario, BindingResult result,
RedirectAttributes redirectAttributes){
if(result.hasErrors()) {
return form(usuario);
}
dao.gravar(usuario);
String path = fileSaver.write("arquivos-sumario", sumario);
usuario.setSumarioPath(path);
redirectAttributes.addFlashAttribute("message", "Produto cadastrado com sucesso!");
return new ModelAndView("redirect:/usuario");
}
@RequestMapping( method=RequestMethod.GET)
public ModelAndView listar() {
List<Usuario> usuarios = dao.listar();
ModelAndView modelAndView = new ModelAndView("usuarios");
modelAndView.addObject("usuario", usuarios);
return modelAndView;
}
}