JP
04/02/2020, 12:44 PM@RestController
class RestWebController {
val custStore = mutableListOf<Customer>()
@GetMapping("/getallcustomer")
fun getAllCustomer(): Response {
println("GET: getallcustomer $custStore")
return Response("Done", custStore)
}
@PostMapping("/postcustomer")
fun postCustomer(@RequestBody customer: Customer): Response {
println("POST: postcustomer $customer")
custStore.add(customer)
return Response("Done", customer)
}
}
data class Response(
val status: String = "",
val data : Any
)
data class Customer(
val firstname: String = "",
val lastname: String = ""
)
Mike
04/02/2020, 1:09 PMJP
04/02/2020, 1:20 PMJP
04/02/2020, 1:26 PMreturn "index"
part here make the application look for index.html
in my templates? Is this triggered by the @Controller
annotation?
@Controller
class WebController {
@GetMapping("/")
fun homepage(): String {
return "index"
}
}
Mike
04/02/2020, 1:37 PMindex
question, that depends on what other Spring dependencies you have brought in, but it's been a long time since I've look at templating options.
I think the basic one will just return "index"
as the response since you've defined an endpoint at /
. If you didn't have that, then it would look in the static
folder for an index.html
JP
04/02/2020, 1:46 PMnicholasnet
04/05/2020, 2:13 PM