2
I am not getting through the HTML page to insert the name and save. Could anyone explain what is happening?
@Entity
public class Livro {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String nome;
@ManyToMany
private List<Autor> autor;
@ManyToOne
private Professor professor;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
}
My controller:
@Controller
@RequestMapping("/livros")
public class LivroController {
@Autowired
private Livros livros;
@RequestMapping("/novo")
public ModelAndView novo(){
return new ModelAndView("Livro");
}
@RequestMapping(method = RequestMethod.POST)
public ModelAndView salvar(Livro livro){
ModelAndView mv= new ModelAndView("Livro");
livros.save(livro);
return mv;
}
HTML page:
<section layout:fragment="conteudo01">
<form action="from-horizontal" method="POST" th:action="@{/livros/novo}" th:object="${livros}">
<div class="panel panel-default">
<h1 class="panel-tittle">Casastro de professor</h1>
</div>
<div class="panel-body">
<label for="nome" class="col-sm-1 contrl-label">Matricula:</label>
<div class="col-sm-2">
<input type="text" class="from-control" id="nome" th:value="*{nome}"/>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default">Sign in</button>
</div>
</div>
</form>
Error:
Caused by: org.attoparser.Parseexception: Exception evaluating Springel Expression: "name" (template: "Book" - line 31, col 54)
I don’t understand this mistake.
Documentation of the Thymeleaf:
<input type="text" id="datePlanted" name="datePlanted" th:value="*{datePlanted}"