假如,在某Spring Boot应用Xxx的控制器类Yyy中有如下处理方法: @RequestMapping("/findAuthor_id1/{id}") public List<Article> findByAuthor_id1(@PathVariable("id") Integer id) { ...... } 那么,我们可以使用下列哪个REST风格的URL访问上述处理方法( )。 A. http://localhost:8080/Xxx/findArticleByAuthor_id1/id="2" B. http://localhost:8080/Xxx/findArticleByAuthor_id1/"2" C. http://localhost:8080/Xxx/findArticleByAuthor_id1/{2} D. http://localhost:8080/Xxx/findArticleByAuthor_id1/2
时间: 2023-08-01 12:06:15 浏览: 74
正确 REST 风格的 URL 访问上述处理方法是 D. http://localhost:8080/Xxx/findArticleByAuthor_id1/2。
解析:@RequestMapping("/findAuthor_id1/{id}") 中的 {id} 表示占位符,即 URL 可以通过占位符来接收参数,因此使用 http://localhost:8080/Xxx/findAuthor_id1/2 的方式可以将 "2" 作为参数传递给处理方法 findByAuthor_id1。