springboot报错:Request method 'GET' not supported

来源:互联网 发布:js更新json值 编辑:程序博客网 时间:2024/06/10 01:18

controller类:

package com.rabbit.controller;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.web.bind.annotation.PostMapping;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RestController;import com.rabbit.hello.HelloSender1;@RestController@RequestMapping("/rabbit")public class RabbitTest {        @Autowired    private HelloSender1 helloSender1;        @PostMapping("/hello")    public void hello() {        helloSender1.send();    }}

结果通过地址栏访问hello方法报不支持Get访问,原来地址栏输入链接默认都是Get方式,将@PostMapping改为@RequestMapping就可以了

阅读全文
0 0
原创粉丝点击