我的服务有点问题。当我收到json列表时,日期为空,我认为这是因为json没有日期类型。 有没有办法解决它并收到真实日期而不是空?
我要发布一些重要的代码,非常感谢你。
的ServiceController
@RequestMapping(value="evento9", method=RequestMethod.GET, produces = "application/json")
public ResponseEntity<?> evento9(@RequestParam(value="localizacion", required=true) String localizacion){
ListaEventos listaComodin = new ListaEventos();
listaComodin.setListaEvento(eventoDAO.findBySalaEvento(localizacion));
return new ResponseEntity<>(listaComodin,HttpStatus.OK);
}
控制器
Client client = ClientBuilder.newClient();
WebTarget webResource = client.target("http://localhost:8086").path("evento9")
.queryParam("localizacion", localizacion);
ListaEventos eventoComodin = webResource.request().accept("application/json").get(ListaEventos.class);
request.setAttribute("eventos", eventoComodin.getListaEvento());
request.getServletContext().getRequestDispatcher("/busqueda.jsp").forward(request,response);
获取y设置
@JsonDeserialize(using = CustomJsonDateDeserializer.class)
public Date getFechaEvento() {
return this.fechaEvento;
}
@JsonDeserialize(using = CustomJsonDateDeserializer.class)
public void setFechaEvento(Date fechaEvento) {
this.fechaEvento = fechaEvento;
}