File tree Expand file tree Collapse file tree
java/org/launchcode/codingevents/controllers Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33import org .springframework .stereotype .Controller ;
44import org .springframework .web .bind .annotation .GetMapping ;
5+ import org .springframework .web .bind .annotation .PostMapping ;
56import org .springframework .web .bind .annotation .RequestMapping ;
67import org .springframework .ui .Model ;
8+ import org .springframework .web .bind .annotation .RequestParam ;
79
810import java .util .ArrayList ;
911import java .util .List ;
1214 * Created by Chris Bay
1315 */
1416@ Controller
15- @ RequestMapping ("events" )
17+ @ RequestMapping ("events/ " )
1618public class EventController {
1719
20+ private static List <String > events = new ArrayList <>();
21+
1822 @ GetMapping
1923 public String displayAllEvents (Model model ) {
20- List <String > events = new ArrayList <>();
21- events .add ("Code With Pride" );
22- events .add ("Strange Loop" );
23- events .add ("Apple WWDC" );
24- events .add ("SpringOne Platform" );
2524 model .addAttribute ("events" , events );
2625 return "events/index" ;
2726 }
27+
2828 @ GetMapping ("create" )
29- public String renderCreateEventForm () {
29+ public String displayCreateEventForm () {
3030 return "events/create" ;
3131 }
3232
33+ @ PostMapping ("create" )
34+ public String createEvent (@ RequestParam String eventName ) {
35+ events .add (eventName );
36+ return "redirect:" ;
37+ }
38+
3339}
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ <h1>Coding Events</h1>
1010
1111< nav >
1212 < ul >
13- < li > < a href ="/ events "> All Events</ a > </ li >
13+ < li > < a href ="events/ "> All Events</ a > </ li >
1414 </ ul >
1515</ nav >
1616
You can’t perform that action at this time.
0 commit comments