File tree Expand file tree Collapse file tree 4 files changed +52
-0
lines changed
src/com/luv2code/springdemo/mvc Expand file tree Collapse file tree 4 files changed +52
-0
lines changed Original file line number Diff line number Diff line change 1+ package com .luv2code .springdemo .mvc ;
2+
3+ import org .springframework .stereotype .Controller ;
4+ import org .springframework .web .bind .annotation .RequestMapping ;
5+
6+ @ Controller
7+ public class HelloWorldController {
8+
9+ // need a controller method to show the initial HTML form
10+
11+ @ RequestMapping ("/showForm" )
12+ public String showForm () {
13+ return "helloworld-form" ;
14+ }
15+
16+ // need a controller method to process the HTML form
17+
18+ @ RequestMapping ("/processForm" )
19+ public String processForm () {
20+ return "helloworld" ;
21+ }
22+ }
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ <html >
3+ <head >
4+ <title >Hello World - Input Form</title >
5+ </head >
6+ <body >
7+ <form action =" processForm" method =" GET" >
8+
9+ <input type =" text" name =" studentName" placeholder =" What's your name?" />
10+ <input type =" submit" />
11+
12+ </form >
13+ </body >
14+ </html >
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ <html >
3+
4+ <body >
5+
6+ Hello World of Spring!
7+ <br ><br >
8+ Student name: ${ param. studentName }
9+
10+ </body >
11+
12+ </html >
Original file line number Diff line number Diff line change 33
44<body >
55 <h2 >Spring MVC Demo - Home Page</h2 >
6+
7+ <hr >
8+
9+ <a href =" showForm" >Hello World form</a >
610</body >
711
812</html >
You can’t perform that action at this time.
0 commit comments