How use PUT method in Springboot Restcontroller?

前端 未结 5 1568
花落未央
花落未央 2021-02-09 14:37

Am developing an application using Spring boot.I tried with all representations verbs like GET, POST , DELETE all are working fine too. By using PUT method, it\'s not supporting

5条回答
  •  时光说笑
    2021-02-09 15:08

    I meet the same issue with spring boot 1.5.*,I fixed it by follow:

    @RequestMapping(value = "/nick", method = RequestMethod.PUT)
    public Result updateNick(String nick) {
        return resultOk();
    }
    

    Add this bean

    @Bean
    public TomcatEmbeddedServletContainerFactory tomcatEmbeddedServletContainerFactory() {
        return new TomcatEmbeddedServletContainerFactory(){
            @Override
            protected void customizeConnector(Connector connector) {
                super.customizeConnector(connector);
                connector.setParseBodyMethods("POST,PUT,DELETE");
            }
        };
    }
    

    see also

    https://stackoverflow.com/a/25383378/4639921
    https://stackoverflow.com/a/47300174/4639921

提交回复
热议问题