1

所以我可以在 Python 的文档中看到你可以去:

raise endpoints.NotFoundException(message) 

https://developers.google.com/appengine/docs/python/endpoints/exceptions

所以在Java中我试过:

resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "Event has no attendee!");

当我在 Java 中执行此操作时,我得到:

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "badRequest",
    "message": "com.google.appengine.repackaged.org.codehaus.jackson.map.JsonMappingException: Can not construct instance of javax.servlet.http.HttpServletResponse, problem: abstract types can only be instantiated with additional type information\n at [Source: N/A; line: -1, column: -1]"
   }
  ],
  "code": 400,
  "message": "com.google.appengine.repackaged.org.codehaus.jackson.map.JsonMappingException: Can not construct instance of javax.servlet.http.HttpServletResponse, problem: abstract types can only be instantiated with additional type information\n at [Source: N/A; line: -1, column: -1]"
 }
}

我该如何正确地做到这一点?谢谢!

4

1 回答 1

0

请参阅我上面的评论,这非常适合我的需要。

于 2013-09-16T16:51:33.100 回答