我很不确定从哪里开始...... 我使用Jersey创建了2个端点,其中一个端点按预期工作,而另一个端点给出了404响应。但是,如果我删除查询参数,那么它可以工作。
@GET
@Path("/note")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Gets a saved note", notes = "Gets a saved note from the database")
@ApiResponses(value = {@ApiResponse(code = HttpServletResponse.SC_OK,
message = "The saved note was successfully gotten",
response = Note.class), @ApiResponse(code = HttpServletResponse.SC_NOT_FOUND,
message = "Could not find the note",
response = ErrorMessage.class)})
Response getNote(
@ApiParam(value = "The ID of the note to get", required = true) @QueryParam("noteID") String noteID) throws
Exception;
@GET
@Path("/note/root")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Gets all root elements", notes = "Gets all elements that do not have a parent relation")
@ApiResponses(value = {@ApiResponse(code = HttpServletResponse.SC_OK,
message = "All root notes",
response = Note.class)})
Response getRootNotes() throws Exception;
这是我使用的界面。 getNote端点给出404,getRootNotes给出我期望的响应。
@Component
public class NotesBean implements Notes
{
@Override
public Response getNote(
@ApiParam(value = "The ID of the note to get", required = true) @QueryParam("note") String noteID) throws
Exception
{
return Response.status(HttpServletResponse.SC_NOT_IMPLEMENTED).build();
}
@Override
public Response getRootNotes() throws Exception
{
return Response.status(HttpServletResponse.SC_NOT_IMPLEMENTED).build();
}
}
至少可以说实施是微不足道的
如果有任何用处,我使用tomcat9来托管它。
另外,在我的web.xml中,我相信我已正确映射:
<servlet-mapping>
<servlet-name>jersey</servlet-name>
<url-pattern>/api/*</url-pattern>
</servlet-mapping>
任何人都知道可能出现什么问题?