1
I’m trying to make this springboot code, become a code in Webapi
@RequestMapping("/deletarEvento")
public String deletarEvento(long codigo)
{
Evento evento = er.findByCodigo(codigo);
er.delete(evento);
return "redirect:/eventos";
}
More when I try to do
@RequestMapping(value="/deletarEvento", method=RequestMethod.DELETE)
public String deletarEvento(long codigo)
{
Evento evento = er.findByCodigo(codigo);
er.delete(evento);
return "redirect:/eventos";
}
he gives this error :
There was an Unexpected error (type=Bad Request, status=400).
Failed to Convert value of type 'java.lang.String' to required type 'long';
nested Exception is java.lang.NumberFormatException: For input string: "deletarEvento"
Event Class
package com.vestibulartio.models;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Generatedvalue;
import javax.persistence.Generationtype;
import javax.persistence.Id;
import javax.persistence.Onetomany;
import javax.persistence.Table;
@Entity
@Table(name="event")
public class Event{
@Id
@Column(name="codigo")
private Long codigo;
//@OneToMany
//private List<Convidado> convidado;
@Column(name="nome")
private String nome;
@Column(name="local")
private String local;
@Column(name="data")
private String data;
@Column(name="horario")
private String horario;
public Long getCodigo() {
return codigo;
}
public void setCodigo(Long codigo) {
this.codigo = codigo;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public String getLocal() {
return local;
}
public void setLocal(String local) {
this.local = local;
}
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
public String getHorario() {
return horario;
}
public void setHorario(String horario) {
this.horario = horario;
}
} package com.vestibulartio.models;
import java.util.List;
import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Generatedvalue; import javax.persistence.Generationtype; import javax.persistence.Id; import javax.persistence.Onetomany; import javax.persistence.Table;
@Entity @Table(name="event") public class Event{
@Id
@Column(name="codigo")
private Long codigo;
//@OneToMany
//private List<Convidado> convidado;
@Column(name="nome")
private String nome;
@Column(name="local")
private String local;
@Column(name="data")
private String data;
@Column(name="horario")
private String horario;
public Long getCodigo() {
return codigo;
}
public void setCodigo(Long codigo) {
this.codigo = codigo;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public String getLocal() {
return local;
}
public void setLocal(String local) {
this.local = local;
}
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
public String getHorario() {
return horario;
}
public void setHorario(String horario) {
this.horario = horario;
}
}
You can post the class
Evento
?– StatelessDev
@Statelessdev placed
– Nuck