Spring Boot添加= post方法中的数据之后

Maifee Ul Asad:

我有休息服务,Spring Boot应用程序和POST数据方法,这是它的样子:

@PostMapping("/data")
    Datum newDatum(@RequestBody String data) {
        return repository.save(new Datum(data));
    }

我在终端中使用此请求:

curl -X POST“内容类型:application / json” -d“ abc” http:// localhost:8080 / data

这给我返回了:

{"dID":7,"data":"abc="}

每次额外的=,这就是错误,我该如何解决?

Datum 类:

@Data
@Entity
public class Datum {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    Long datumID;
    private String data;
    public Datum(){}
}

否要覆盖的字符串方法。

它也使我卷曲:(3)端口号以“”错误结尾,但数据仍被保存

Maifee Ul Asad:

这个命令对我有用

curl -X POST -H "Content-Type: application/json" -d "data_test" http://localhost:8080/data

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

使用 spring boot 在 postgreSql 中添加静态数据的最佳方法

在Spring Boot中添加.crt以启用SSL

Spring Boot 在链接中添加了“es”

angular 4 spring boot数据在angular 4中的订阅方法之后为空

在Spring Boot中添加属性值的正确方法是什么

检查启动后添加特定数据-Spring Boot

如何在外部库中添加Spring Boot支持?

Spring Boot在错误响应实体中添加请求主体

在Spring Boot中添加多个跨源URL

在Spring Boot中向日志文件添加时间戳?

在Spring Boot中添加外部静态文件(css,js,png ...)

如何在Spring-boot中添加静态Web内容

Spring Boot在控制器的每个动作中添加if语句

在Spring中动态添加Google Maps(MVC或Boot)

在 Spring Boot 应用程序中添加 angular

如何在Spring Boot中添加外键null值?

在 Spring boot 中添加超过 65535 个条目 jar

无法将Spring数据的依赖项添加到Spring Boot中

在Spring Boot中@Transactional方法之后,实体在Exposed之后不持久

如果 post 方法 spring boot

如何使用postgresql在Spring Boot中的addScaler()方法中添加枚举值?

如何通过联接在Spring Data JPA和Spring Boot中添加计数字段

在Spring Boot中将@Conditional添加到现有的Spring注释中

在Spring Boot应用程序中添加spring-boot-starter-security会导致错误“ entityManagerFactory”或“ persistenceUnitName”

在Spring-Boot简介之后,“无法找到合适的主类,请添加'mainClass'属性”

在 spring boot 中过滤数据

将数据添加到数据库(相关表)Spring Boot

如何在Spring Boot中手动将数据添加到Redis并获取缓存的数据?

无法使用连接到PostgreSQL数据库的Spring Boot添加和更新值