其他分享
首页 > 其他分享> > Spring REST,Kotin和默认的原始参数会导致错误

Spring REST,Kotin和默认的原始参数会导致错误

作者:互联网

我收到一个错误:

Optional long parameter ‘count’ is present but cannot be translated into a null value due to being declared as a primitive type. Consider declaring it as object wrapper for the corresponding primitive type

当我尝试调用此REST控制器时.

    @RequestMapping("/api/audio/tracks", produces = arrayOf(APPLICATION_JSON_VALUE))
    interface SomeApi {


        @RequestMapping(method = arrayOf(GET))
        fun list(@RequestParam("count", defaultValue = "10") count: Long): Any
    }

春天不看defaultValue吗?

如何解决这类问题?

!Kotlin默认设置也不起作用

解决方法:

我找到了解决方案:

原因是因为界面.当我在实现中放置@RequestParam(“count”,required = false,defaultValue =“10”)时,一切都开始工作.

标签:spring-rest,spring,kotlin
来源: https://codeday.me/bug/20190828/1750177.html