怎么往redirect:/indexblog/{id}传@GetMapping("comment/{blogId}/{id}/delete")里的id,public String delete(@PathVariable Long blogId, @PathVariable Long id, Comment comment, RedirectAttributes attributes, Model model){ commentService.deleteComment(comment,i
时间: 2024-02-12 12:08:34 浏览: 133
在你的@GetMapping("comment/{blogId}/{id}/delete")中,id是指评论的id,而在redirect:/indexblog/{id}中的id是指博客的id。如果你想要在redirect中传递评论的id,可以将其作为参数添加到redirect中,如下所示:
```
redirect:/indexblog/{blogId}?commentId={id}
```
然后,在你的indexblog页面中,可以通过request.getParameter("commentId")来获取评论的id。注意,这种方式只适用于传递一个或少量的参数,如果需要传递多个参数,建议使用其他方式,如Session或者ModelAndView等。
相关问题
@PutMapping("/{id}")@DeleteMapping("/{id}")@PostMapping("/addAdvert")@GetMapping区别
这是四个不同的HTTP请求方法:
1. @GetMapping:用于处理HTTP GET请求方法,表示从服务器获取资源。
2. @PostMapping:用于处理HTTP POST请求方法,表示向服务器提交数据。
3. @PutMapping:用于处理HTTP PUT请求方法,表示更新服务器上的资源。
4. @DeleteMapping:用于处理HTTP DELETE请求方法,表示从服务器删除资源。
在Spring MVC框架中,根据HTTP请求方法的不同,选择相应的注解来处理请求。这样可以使代码更加清晰易懂,也符合RESTful风格的设计。
@GetMapping("/") public String goToPageSimple() { return "redirect:/order/0/10"; }
这段代码是一个Java方法,使用了Spring框架的@GetMapping注解,表示该方法处理GET请求,请求的路径是"/"。该方法的返回值是一个字符串,"redirect:/order/0/10"表示将请求重定向到路径"/order/0/10"。这个方法似乎是用于重定向页面,将用户导向到订单页面的第一页,每页显示10个订单。
阅读全文
相关推荐
![-](https://img-home.csdnimg.cn/images/20241231044930.png)
![-](https://img-home.csdnimg.cn/images/20241231044901.png)
![-](https://img-home.csdnimg.cn/images/20241231044930.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)