john is a software developer in FIS technoloay and he has used REST API in his web Application, now he wants toaccess a single student object in result on the basis of given ID What code snippet wil he use to get the desiredresult? OA OB oc OD @PostMapping("/student/<studentId ")public StudentBo getStudentById(@PathVariable int studentId) @GetMapping("/student/<studentId1")public StudentBo getStudentById(@PathVariable int studentId) @PostMapping("/student/(studentId)")public StudentBo getStudentById(@RequestParam int studentId) @GetMappingMapping("/student/(studentId1")public StudentBo getStudentBvid( @ReguestBody int studentid
时间: 2024-03-21 14:42:58 浏览: 55
read-excel-file-in-java.zip_in_java excel_read_excel
The correct answer is option B:
```java
@GetMapping("/student/{studentId}")
public StudentBo getStudentById(@PathVariable int studentId)
```
Explanation:
- `@GetMapping` is used for HTTP GET requests, which is appropriate for retrieving data.
- `"/student/{studentId}"` is the endpoint URL pattern, where `studentId` is a path variable that will be filled in with the actual student ID at runtime.
- `@PathVariable` is used to bind the value of `studentId` from the URL to the method parameter.
- `public StudentBo` specifies the return type of the method as `StudentBo`, which represents a single student object.
- The method body would contain the logic for retrieving the student object from the database or any other data source based on the given `studentId`.
Therefore, option B is the correct answer.
阅读全文