如何在Springboot Restcontroller中使用PUT方法? [英] How use PUT method in Springboot Restcontroller?

查看:391
本文介绍了如何在Springboot Restcontroller中使用PUT方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Spring boot开发应用程序。我尝试使用所有表示动词,如GET,POST,DELETE都可以正常工作。通过使用PUT方法,它不支持弹簧启动。我是否需要添加任何新配置。

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 in spring boot. Whether I need to add any new configuration.

Put方法仅适用于请求没有任何参数。如果我添加任何查询参数或表单数据,它不起作用。敬请任何专业人士帮我解决这个问题。

Put method works only the request not have any parameters. If i add any query parameter or form data it doesnt work. Kindly any expertize will help me to solve this issue.

@RequestMapping("/student/info")
@RequestMapping(method = RequestMethod.PUT)
public @ResponseBody String updateStudent(@RequestParam(value = "stdName")String stdName){
    LOG.info(stdName);
    return "ok";
}




不支持请求方法'PUT'

Request method 'PUT' not supported


推荐答案

此代码可以正常工作。您必须在课程级别或函数
级别指定请求映射。

@RequestMapping(value = "/student/info", method = RequestMethod.PUT)
public @ResponseBody String updateStudent(@RequestBody Student student){
 LOG.info(student.toString());
 return "ok";
}

这篇关于如何在Springboot Restcontroller中使用PUT方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆