While recently initiating a project using Spring MVC, we ware trying to discover some technical know how’s. We were doing that at random but one of my friend and college Abdullah Al Hasib made a skeleton project where almost all start-up issues are solved. He also made a documentation for us which further edited by Sheikh Nabil Mohammad also a Friend and college.
I am just including all of this here.
- Create web application with spring frame work.
- Edit the beans attribute in dispatcher-servlet.xml file.
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
then add in the beans
<!– Scans the classpath of this application for @Components to deploy as beans –>
<context:component-scan base-package=”controller” />
<!– Configures the @Controller programming model –>
- Now this project has become anotation based spring web project.
- Crate standard packages controller, model, service packages in the source packages where controller stands for receiving all the client request and send response for the corresponding request. Ser vice package is to interect with the database and provide required information to the controller.
Concepts covered in this Project:
In this project we created some basic example of spring web application such as
1. How to send data to the server by form.
2. How to send data to the server by Ajax.
4. How to send JSON data to the server by Ajax using jquery.
5. How to request to server using anchor (<a href=””></a>).
7. how to work with basic annotation @Controller , @RequestMapping , @RequestParam , @ResponseBody , @ModelAttribute etc.
1. editStudent.jsp and controller.editStudent() (POST) method provide an example that how to send data to the server using form (<form>).
2. addStudent.jsp and controller.addStudent() method provides an example that how to send data to the server by Ajax.
3. addEmployee.jsp and controller.addEmployee() method provide an example that how to send JSON data to the server using jquery Ajax method.
4. (studentList.jsp and controller.getStudentList() methotd provide an example that how to request server by using anchor (<a href=””></a>)
Note that, we put “resource” folder in the “web Pages” folder. we can put “resource” folder in the “WEB-INF/jsp/” directory but any content in the “WEB INF” folder becomes private. Any content in the “WEB-INF” folder cannot be accessed by the browser that’s why we put “resource” folder in the “web pages” folder out of the “WEB-INF” folder.
Important URL :