Spring MVC simple project Flow: web.xml --> dispatcher-servlet.xml -->(data) controller --> (data)view pages --> Client
Steps for creating Spring MVC Project:
- Create a new Maven project with archtype webapp of springmvc
- Add server Download the server that you want Go to server window -> click on add servers -> select server name -> add the location of server and select the JRE version -> Shift you project to configured -> Finish
- Click on project's folder -> Build path -> Libraries -> Add library -> Server Runtime -> Select the server name
- Open pom.xml file Add "Spring web mvc" dependecy from mvn repository
- Edit the "web.xml" file Add the servlet name that will have the dispatcher servlets name in my case it is "nikita" and servlet base class(controller) Add the servlet mappings that will have the servlet name and url mappings(usually / for all the urls)
- Create dispatcher servlet xml file, in my case its "nikita-servlet.xml" file Add a bean tag to specify name spaces Add the base class where the controllers are placed Specify the annotation configuration Add a bean tag to specify add a "View Resolver" and settings such as prefix, suffix
- Add the view pages
- Add the controller classes