Example Spring MVC Form Handling

1. Project structure

   

 

2. File pom.xml

 

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <groupId>com.codewr.form</groupId>

    <artifactId>spring-mvc-form</artifactId>

    <packaging>war</packaging>

    <version>new</version>

    <name>SpringMVC Form Handling Example</name>

 

    <properties>

        <jdk.version>1.7</jdk.version>

        <spring.version>4.1.6.RELEASE</spring.version>

        <hsqldb.version>2.3.2</hsqldb.version>

        <logback.version>1.1.3</logback.version>

        <jcl.slf4j.version>1.7.12</jcl.slf4j.version>

        <jstl.version>1.2</jstl.version>

        <servletapi.version>3.1.0</servletapi.version>

    </properties>

 

    <dependencies>

 

        <dependency>

            <groupId>org.springframework</groupId>

            <artifactId>spring-core</artifactId>

            <version>${spring.version}</version>

            <exclusions>

                <exclusion>

                    <groupId>commons-logging</groupId>

                    <artifactId>commons-logging</artifactId>

                </exclusion>

            </exclusions>

        </dependency>

 

        <!-- Spring Web -->

        <dependency>

            <groupId>org.springframework</groupId>

            <artifactId>spring-webmvc</artifactId>

            <version>${spring.version}</version>

        </dependency>

 

        <!-- Spring Web

        <dependency>

                <groupId>org.springframework</groupId>

                <artifactId>spring-expression</artifactId>

                <version>${spring.version}</version>

        </dependency>

        -->

 

        <!-- Spring JDBC -->

        <dependency>

            <groupId>org.springframework</groupId>

            <artifactId>spring-jdbc</artifactId>

            <version>${spring.version}</version>

        </dependency>

 

        <!-- HyperSQL DB -->

        <dependency>

            <groupId>org.hsqldb</groupId>

            <artifactId>hsqldb</artifactId>

            <version>${hsqldb.version}</version>

        </dependency>

 

 

        <dependency>

            <groupId>org.slf4j</groupId>

            <artifactId>jcl-over-slf4j</artifactId>

            <version>${jcl.slf4j.version}</version>

        </dependency>

 

        <dependency>

            <groupId>ch.qos.logback</groupId>

            <artifactId>logback-classic</artifactId>

            <version>${logback.version}</version>

        </dependency>

 

        <!-- jstl -->

        <dependency>

            <groupId>jstl</groupId>

            <artifactId>jstl</artifactId>

            <version>${jstl.version}</version>

        </dependency>

 

        <dependency>

            <groupId>javax.servlet</groupId>

            <artifactId>javax.servlet-api</artifactId>

            <version>${servletapi.version}</version>

            <scope>provided</scope>

        </dependency>

 

    </dependencies>

 

    <build>

 

        <plugins>

 

            <plugin>

                <groupId>org.apache.maven.plugins</groupId>

                <artifactId>maven-compiler-plugin</artifactId>

                <version>3.3</version>

                <configuration>

                    <source>${jdk.version}</source>

                    <target>${jdk.version}</target>

                </configuration>

            </plugin>

 

            <!-- embedded Jetty server, for testing -->

            <plugin>

                <groupId>org.eclipse.jetty</groupId>

                <artifactId>jetty-maven-plugin</artifactId>

                <version>9.2.11.v20150529</version>

                <configuration>

                    <scanIntervalSeconds>10</scanIntervalSeconds>

                    <webApp>

                        <contextPath>/spring-mvc-form</contextPath>

                    </webApp>

                </configuration>

            </plugin>

 

            <!-- configure Eclipse workspace -->

            <plugin>

                <groupId>org.apache.maven.plugins</groupId>

                <artifactId>maven-eclipse-plugin</artifactId>

                <version>2.9</version>

                <configuration>

                    <downloadSources>true</downloadSources>

                    <downloadJavadocs>true</downloadJavadocs>

                    <wtpversion>2.0</wtpversion>

                    <wtpContextName>spring-mvc-form</wtpContextName>

                </configuration>

            </plugin>

 

        </plugins>

    </build>

</project>

 

3. Run web:

http://localhost:8080/spring-mvc-form/users

 

 

Click Add User:

 

Click Query:

Click Update

Click Delete

 

4. Link down full code:

https://github.com/sieurobo196/Spring-MVC/tree/master/SpringMVC-Form-Handle-Example