我试着做了如下的发帖请求:
http://localhost:8080/root/initVar/id/2->error
http://localhost:8080/root/initVar/id?2->error
但是当我从方法中返回Int数据类型时,它不起作用。
请让我知道如何修正这个错误。
请注意,这个方法返回Int
:
@RestController
@RequestMapping("root")
class Controller1 {
val sayHiLazy by lazy {
"hi from get"
}
@GetMapping(value = "/sayHi")
@ResponseBody
fun sayHi() : String {
return sayHiLazy
}
@PostMapping("/initVar/id")
@ResponseBody
fun initVar(@PathVariable id : Int) : Int {
return 11
}
}to use spring annotation with koltin in intellij. i used spring annotation with java projects in intellij. but for koltin, it does not work.
在下面的示例中,HelloController带有红色下划线,我收到以下警告:
classes annotated with @Configurations cannto be implicily subclassed and must be final
请让我知道怎么做
控制器1
@SpringBootConfiguration
@RequestMapping("/app")
public class HelloController {
@RequestMapping(value = "/hello")
fun SayHello(): String {
return "success"
}
}