Skip to content

Instantly share code, notes, and snippets.

@stefanozanella
Created January 12, 2021 09:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stefanozanella/d9e7cf47eaedc09efe233e7f708d46d5 to your computer and use it in GitHub Desktop.
Save stefanozanella/d9e7cf47eaedc09efe233e7f708d46d5 to your computer and use it in GitHub Desktop.
package me.stefanozanella.sampleapp
import org.springframework.stereotype.Controller
import org.springframework.ui.Model
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.ModelAttribute
import org.springframework.web.bind.annotation.PostMapping
@Controller
class StockPurchaseController {
@GetMapping("/")
fun newStockPurchase(model: Model): String {
model.addAttribute("stockPurchase", StockPurchase())
return "addStockPurchase"
}
@PostMapping("/stock_purchase")
fun addStockPurchase(@ModelAttribute stockPurchase: StockPurchase): String {
// TODO Do something with the model we get from the view
return "stockPurchaseCreated"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment