如何在Restangular POST中处理HTTP 204“无内容”?

时间:2015-03-24 09:21:12

标签: javascript angularjs rest restangular

我有一个REST服务来记录用户界面日志。 JavaScript是:

Restangular.all("log_tutor").post(information);

它可以工作,我获得了一个HTTP响应" 204没有内容",这是该服务的预期。 但是它写在FireFox控制台"找不到元素"。

怎么可能告诉Restangular不要期望来自这个电话的数据?或仅处理此呼叫的HTTP 204代码?

JAVA服务是:

         @Provider
        @Path("log_tutor")
        public class TutorTraceRESTFacade {

        . . .

            @POST
            @Consumes({"application/xml", "application/json"})
            @Transactional
            @RolesAllowed("TUTOR")  
            public Response create(TutorTraceDetail _trace, @Context HttpServletRequest req) {
                _trace.setMessageReceivedTimestamp(new Date());
                HttpSession session = req.getSession();
                String sessionId = session.getId();
                LoginUser user = FormIDApplication.getInstance().getConnectedUser(sessionId);
                Long c = tutorTraceFacade.create(user.getLogin(), _trace);
                return Response.created(URI.create(c.toString())).build();
            }   
    . . .
}

谢谢。

1 个答案:

答案 0 :(得分:0)

考虑到您有一个Javascript对象//Bar color. [[UINavigationBar appearance] setBarTintColor:UIColorFromRGB(0xe58509)]; //Bar text. NSShadow *shadow = [[NSShadow alloc] init]; shadow.shadowColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.0]; shadow.shadowOffset = CGSizeMake(0, 0); [[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys: [UIColor colorWithRed:245.0/255.0 green:245.0/255.0 blue:245.0/255.0 alpha:1.0], NSForegroundColorAttributeName, shadow, NSShadowAttributeName, [UIFont fontWithName:@"Heiti SC" size:20.0], NSFontAttributeName, nil]]; ,其中包含您要保存的数据,我会尝试:

logEntry