StudentServiceRs.java 文件源码

java
阅读 17 收藏 0 点赞 0 评论 0

项目:JEE7-Demo 作者:
@POST
@Path("/update/{studentId}")
@Produces({ "application/json" })
public Response update(@NotNull @Digits(integer = 7, fraction = 0) @PathParam("studentId") String studentId,
        @NotNull Student student) throws URISyntaxException {
    try {
        service.update(studentId, student);
        //Here there was a bug because I forgot that EJBException swallow RuntimeException and NoResultException is a Runtime.
        //To solve that problem I defined NoResultException as an ApplicationException in the ejb-jar.xml
    } catch (NoResultException e) {
        return Response.status(Response.Status.NOT_FOUND).build();
    }       
    return Response.status(200).contentLocation(new URI("students/byStudentId/" + student.getStudentId())).build();
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号