Tuesday, February 20, 2024 11:00 AM
In today's session we will start our next module Spring MVC
---------------------------------------------------------
what is Spring MVC ?
- MVC Stands for model view and controller
- model : in java object structure or pojo class known as model
- view : view is nothing html or jsp pages in MVC project
- Controller : controller is java classes which manages HTTP request and Responses
---------------------------------------------------------------------------------
where we use MVC module ?
- Sping MVC is use to create Webapplication's
- Webapplication can be access from everywere through network.
- Webapplication required servers to run the application.
--------------------------------------------------------------------------------
what is webapplication ?
- the aaplication which running on server and can be acces every where globaly known as
webapplication.
- webaaplication is the combination of client side app and server side app.
--------------------------------------------------------------------------------------
Steps to install and configure apache tomcat server
-------------------------------------------------------------------
- download apache tomcat server .exe file 8.0 and above version
link : https://archive.apache.org/dist/tomcat/tomcat-8/v8.0.33/bin/
- install apache tomcat server in your computer
- configure apache server to STS ide
--------------------------------------------------------------------
Steps to create Spring MVC Project.
-- create maven project
- right click project explorer -> new -> maven project -> next -> select archytype webapp
-> grouppID (package name) -> Artifact Id (project name).
-- configure apache server to project
- rigth click project -> properties -> targetd runtime -> check apache server -> apply and close
-- create java folder is src/main path through system
-- add maven dependency of spring webmvc in pom.xml file
<!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.3.30</version>
</dependency>
-- declare DispatcherServlet in web.xml
<web-app>
<display-name>Archetype Created Web Application</display-name>
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
-- declare spring-servlet.xml
<beans>
<context:component-scan base-package="com.cjc"/>
</beans>
-----------------------------------------------------------------------------------------------------