package Ġcom . t urre ta . sb . sm vc . kotlin . controllers čĊč Ċ import Ġcom . t urre ta . sb . sm vc . kotlin . domain . Student č Ċ import Ġcom . t urre ta . sb . sm vc . kotlin . forms . Create Student Form č Ċ import Ġcom . t urre ta . sb . sm vc . kotlin . services . Student Service č Ċ import Ġorg . springframework . beans . factory . annotation . Autowired č Ċ import Ġorg . springframework . stereotype . Controller č Ċ import Ġorg . springframework . ui . Model č Ċ import Ġorg . springframework . web . bind . annotation . PathVariable č Ċ import Ġorg . springframework . web . bind . annotation . RequestMapping č Ċ import Ġorg . springframework . web . bind . annotation . Request Method čĊč Ċ /** čĊ Ġ* ĠCreated Ġby ĠT urre ta . com Ġon Ġ 1 6 / 6 / 2 0 1 7 . čĊ Ġ*/ č Ċ @ Controller č Ċ class ĠStudent Controller Ġ{ čĊčĊĠĠĠ Ġ@ Autowired čĊĠĠĠ Ġlateinit Ġvar Ġstudent Service : ĠStudent Service čĊčĊĠĠĠ Ġ@ RequestMapping ("/ students ") čĊĠĠĠ Ġfun Ġlist Students ( model : ĠModel ) Ġ: ĠString Ġ{ čĊĠĠĠĠĠĠĠ Ġmodel . addAttribute (" students ", Ġstudent Service . get Students ()) čĊĠĠĠĠĠĠĠ Ġreturn Ġ" students " čĊĠĠĠ Ġ} čĊčĊĠĠĠ Ġ@ RequestMapping ("/ student /{ student Id }") čĊĠĠĠ Ġfun Ġfind Student (@ PathVariable (" student Id ") Ġs Id : ĠString , Ġmodel : ĠModel ) Ġ: ĠString Ġ{ čĊĠĠĠĠĠĠĠ Ġmodel . addAttribute (" student ", Ġstudent Service . find Student ById ( sId )) čĊĠĠĠĠĠĠĠ Ġreturn Ġ" student " čĊĠĠĠ Ġ} čĊčĊĠĠĠ Ġ@ RequestMapping ( value ="/ student ", Ġmethod Ġ= ĠarrayOf ( Request Method . POST )) čĊĠĠĠ Ġfun Ġadd Student ( create Student Form : ĠCreate Student Form , Ġmodel : ĠModel ) Ġ: ĠString Ġ{ čĊčĊĠĠĠĠĠĠĠ Ġstudent Service . create Student ( Student ( čĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġstudent Id Ġ= Ġcreate Student Form . student Id !! , čĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠlastName Ġ= Ġcreate Student Form . lastName !! , čĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠfirstName Ġ= Ġcreate Student Form . firstName !! )) čĊčĊĠĠĠĠĠĠĠ Ġreturn Ġ" redirect :/ student /" Ġ+ Ġcreate Student Form . student Id čĊĠĠĠ Ġ} čĊčĊĠĠĠ Ġ@ RequestMapping ( value ="/ student ") čĊĠĠĠ Ġfun Ġcreate Student Page ( model : ĠModel ) Ġ: ĠString Ġ{ čĊĠĠĠĠĠĠĠ Ġmodel . addAttribute (" student Form ", ĠCreate Student Form ()) čĊĠĠĠĠĠĠĠ Ġreturn Ġ" new - student - form " čĊĠĠĠ Ġ} č Ċ }