rest api 嵌套资源_实施REST API的子资源

rest api 嵌套资源

The next important task now is to implement the sub resources of the students and the courses resource. We want all the registrations of a particular student and all the registrations for a particular course.

现在的下一个重要任务是实现学生的子资源和课程资源。 我们需要特定学生的所有注册以及特定课程的所有注册。

Add the following method in the Course class,

Course类中添加以下方法,

@GET
@Produces(MediaType.APPLICATION_XML)
@Path("/{courseid}/registrations")
public List<Registration> getRegistrationWithCourseID(@PathParam("courseid") int courseID)
{		
	return registrationService.getRegistrationForCourse(courseID);	
}

and, add the following method in the Student class,

然后在Student类中添加以下方法,

@Produces(MediaType.APPLICATION_XML)
@Path("/{studentid}/registrations")
public List<Registration> getRegistrationWithStudentsID(@PathParam("studentid") int studentID)
{
	return registraionService.getRegistrationsForStudent(studentID);
}

翻译自: https://www.studytonight.com/rest-web-service/implementing-sub-resources

rest api 嵌套资源

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值