f-angi
12/18/2015 - 11:34 AM

Liferay resource returning a json

Liferay resource returning a json

    @ResourceMapping("legaleList")
    public void getLegaleList(
        ResourceRequest request, ResourceResponse response, @RequestParam(required = false) final String codAge,
        @RequestParam(required = false) final String siglaProvincia)
        throws Exception {

        ObjectMapper mapper = new ObjectMapper();
        mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY);
        response.setContentType("application/json");
        response.getPortletOutputStream().write(mapper.writeValueAsBytes(legaleDao.getLegaleList(codAge, siglaProvincia)));
    }