Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2015
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. @GET
  2. //@Path("{id}")
  3. @Produces({"text/html", "application/json"})
  4. public Response getNoticia(@QueryParam("id")Long id){ //@PathParam("id")Long id@QueryParam("id") String id, @QueryParam("formato")String formato
  5. dao.open();
  6. dao.begin();
  7. Noticia n = dao.find(Noticia.class,id);
  8. if(n.getAutor() != null){
  9. dao.close();
  10. return Response.ok("<html>\n" +
  11. "<head>\n" +
  12. " <title> Noticias </title>\n" +
  13. "</head>\n" +
  14. "<body>\n" +
  15. " <ul>\n" +
  16. " <li>Título: " + n.getTitulo() + ". Autor: " + n.getAutor() + ". Conteúdo: " + n.getConteudo() + ". Id: " + n.getId() + ". Data: " + n.getData() + "</li>\n" +
  17. " </ul>\n" +
  18. "</body>\n" +
  19. "</html>").build();
  20.  
  21. }else{
  22. dao.close();
  23. return Response.status(Status.NOT_FOUND).build();
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement