Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%@page contentType="text/html" pageEncoding="UTF-8"%>
- <%@taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
- "http://www.w3.org/TR/html4/loose.dtd">
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title>Welcome to Spring Web MVC project</title>
- </head>
- <body>
- <h1>Spring 3 Register!</h1>
- <a href="register.htm">click</a>
- <form:form action="${pageContext.request.contextPath}/register.htm" method="POST" modelAttribute="userForm">
- <table>
- <tr>
- <td colspan="2" align="center">Spring MVC Form Demo - Registration</td>
- </tr>
- <tr>
- <td>User Name</td>
- <td><form:input path="username" /></td>
- </tr>
- <tr>
- <td>Password</td>
- <td><form:password path="password" /></td>
- </tr>
- <tr>
- <td>Email</td>
- <td><form:input path="email" /></td>
- </tr>
- <tr>
- <td>BirthDate (mm/dd/yyyy)</td>
- <td><form:input path="birthDate" /></td>
- </tr>
- <tr>
- <td>Profession</td>
- <td><form:select path="profession" items="${professionList}" /></td>
- </tr>
- <tr>
- <td colspan="2" align="center"><input type="submit" value="Register" /></td>
- </tr>
- </table>
- </form:form>
- </body>
- </html>
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package RegisterInfo;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Map;
- /**
- *
- * @author Harshit Shrivastava
- */
- import RegisterInfo.model.User;
- import org.springframework.stereotype.Controller;
- import org.springframework.web.bind.annotation.ModelAttribute;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.ui.Model;
- @Controller
- @RequestMapping(value = "/register")
- public class RegistrationController {
- @RequestMapping(method = RequestMethod.GET)
- public String viewRegistration(Model model)
- {
- User userForm = new User();
- model.addAttribute("userForm", new User());
- /*List<String> professionList = new ArrayList();
- professionList.add("Developer");
- professionList.add("Designer");
- professionList.add("IT Manager");
- model.put("professionList", professionList);*/
- return "index";
- }
- @RequestMapping(method = RequestMethod.POST)
- public String processRegistration(@ModelAttribute("userForm") User user, Map<String, Object> model)
- {
- System.out.println("Username : " + user.getUserName());
- model.put("userForm", new User());
- return "index";
- }
- }
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package RegisterInfo.model;
- /**
- *
- * @author Harshit Shrivastava
- */
- import java.util.Date;
- public class User {
- private String username;
- private String password;
- private String email;
- private Date birthDate;
- private String profession;
- public String getUserName()
- {
- return username;
- }
- public void setUserName(String username)
- {
- this.username = username;
- }
- public String getPassword()
- {
- return password;
- }
- public void setPassword(String password)
- {
- this.password = password;
- }
- public String getEmail()
- {
- return email;
- }
- public void setEmail(String email)
- {
- this.email = email;
- }
- public Date getBirthDate()
- {
- return birthDate;
- }
- public void setBirthDate(Date birthDate)
- {
- this.birthDate = birthDate;
- }
- public String getProfession()
- {
- return profession;
- }
- public void setProfession(String profession)
- {
- this.profession = profession;
- }
- }
- <?xml version="1.0" encoding="UTF-8"?>
- <web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
- <context-param>
- <param-name>contextConfigLocation</param-name>
- <param-value>/WEB-INF/dispatcher-servlet.xml</param-value>
- </context-param>
- <listener>
- <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
- </listener>
- <servlet>
- <servlet-name>dispatcher</servlet-name>
- <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
- <load-on-startup>2</load-on-startup>
- </servlet>
- <servlet-mapping>
- <servlet-name>dispatcher</servlet-name>
- <url-pattern>/</url-pattern>
- </servlet-mapping>
- <session-config>
- <session-timeout>
- 30
- </session-timeout>
- </session-config>
- <welcome-file-list>
- <welcome-file>redirect.jsp</welcome-file>
- </welcome-file-list>
- </web-app>
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:p="http://www.springframework.org/schema/p"
- xmlns:aop="http://www.springframework.org/schema/aop"
- xmlns:tx="http://www.springframework.org/schema/tx"
- xmlns:context="http://www.springframework.org/schema/context"
- xmlns:mvc="http://www.springframework.org/schema/mvc"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
- http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
- http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd ">
- <bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/>
- <context:component-scan base-package="SpringRegister" />
- <mvc:annotation-driven />
- <!--
- Most controllers will use the ControllerClassNameHandlerMapping above, but
- for the index controller we are using ParameterizableViewController, so we must
- define an explicit mapping for it.
- -->
- <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
- <property name="mappings">
- <props>
- <prop key="index.htm">indexController</prop>
- </props>
- </property>
- </bean>
- <bean id="viewResolver"
- class="org.springframework.web.servlet.view.InternalResourceViewResolver"
- p:prefix="/WEB-INF/jsp/"
- p:suffix=".jsp" />
- <!--
- The index controller.
- -->
- <bean name="indexController"
- class="org.springframework.web.servlet.mvc.ParameterizableViewController"
- p:viewName="index" />
- </beans>
- <?xml version="1.0"?>
- <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <modelVersion>4.0.0</modelVersion>
- <groupId>RegisterInfo</groupId>
- <artifactId>RegisterInfoMaven</artifactId>
- <version>1.0-SNAPSHOT</version>
- <packaging>war</packaging>
- <name>RegisterInfoMaven Maven Webapp</name>
- <url>http://maven.apache.org</url>
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
- <repositories>
- <repository>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- <id>central</id>
- <name>Central Repository</name>
- <url>http://repo.maven.apache.org/maven2</url>
- </repository>
- </repositories>
- <pluginRepositories>
- <pluginRepository>
- <releases>
- <updatePolicy>never</updatePolicy>
- </releases>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- <id>central</id>
- <name>Central Repository</name>
- <url>http://repo.maven.apache.org/maven2</url>
- </pluginRepository>
- </pluginRepositories>
- <build>
- <sourceDirectory>E:My ProjectsJavaRegisterInfoMavensrcmainjava</sourceDirectory>
- <scriptSourceDirectory>E:My ProjectsJavaRegisterInfoMavensrcmainscripts</scriptSourceDirectory>
- <testSourceDirectory>E:My ProjectsJavaRegisterInfoMavensrctestjava</testSourceDirectory>
- <outputDirectory>E:My ProjectsJavaRegisterInfoMaventargetclasses</outputDirectory>
- <testOutputDirectory>E:My ProjectsJavaRegisterInfoMaventargettest-classes</testOutputDirectory>
- <resources>
- <resource>
- <directory>E:My ProjectsJavaRegisterInfoMavensrcmainresources</directory>
- </resource>
- </resources>
- <testResources>
- <testResource>
- <directory>E:My ProjectsJavaRegisterInfoMavensrctestresources</directory>
- </testResource>
- </testResources>
- <directory>E:My ProjectsJavaRegisterInfoMaventarget</directory>
- <finalName>RegisterInfoMaven</finalName>
- <pluginManagement>
- <plugins>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <version>1.3</version>
- </plugin>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <version>2.2-beta-5</version>
- </plugin>
- <plugin>
- <artifactId>maven-dependency-plugin</artifactId>
- <version>2.1</version>
- </plugin>
- <plugin>
- <artifactId>maven-release-plugin</artifactId>
- <version>2.0</version>
- </plugin>
- </plugins>
- </pluginManagement>
- <plugins>
- <plugin>
- <artifactId>maven-clean-plugin</artifactId>
- <version>2.4.1</version>
- <executions>
- <execution>
- <id>default-clean</id>
- <phase>clean</phase>
- <goals>
- <goal>clean</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-install-plugin</artifactId>
- <version>2.3.1</version>
- <executions>
- <execution>
- <id>default-install</id>
- <phase>install</phase>
- <goals>
- <goal>install</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-resources-plugin</artifactId>
- <version>2.5</version>
- <executions>
- <execution>
- <id>default-resources</id>
- <phase>process-resources</phase>
- <goals>
- <goal>resources</goal>
- </goals>
- </execution>
- <execution>
- <id>default-testResources</id>
- <phase>process-test-resources</phase>
- <goals>
- <goal>testResources</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>2.10</version>
- <executions>
- <execution>
- <id>default-test</id>
- <phase>test</phase>
- <goals>
- <goal>test</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.3.2</version>
- <executions>
- <execution>
- <id>default-testCompile</id>
- <phase>test-compile</phase>
- <goals>
- <goal>testCompile</goal>
- </goals>
- </execution>
- <execution>
- <id>default-compile</id>
- <phase>compile</phase>
- <goals>
- <goal>compile</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-war-plugin</artifactId>
- <version>2.1.1</version>
- <executions>
- <execution>
- <id>default-war</id>
- <phase>package</phase>
- <goals>
- <goal>war</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-deploy-plugin</artifactId>
- <version>2.7</version>
- <executions>
- <execution>
- <id>default-deploy</id>
- <phase>deploy</phase>
- <goals>
- <goal>deploy</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-site-plugin</artifactId>
- <version>3.0</version>
- <executions>
- <execution>
- <id>default-site</id>
- <phase>site</phase>
- <goals>
- <goal>site</goal>
- </goals>
- <configuration>
- <outputDirectory>E:My ProjectsJavaRegisterInfoMaventargetsite</outputDirectory>
- <reportPlugins>
- <reportPlugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-project-info-reports-plugin</artifactId>
- </reportPlugin>
- </reportPlugins>
- </configuration>
- </execution>
- <execution>
- <id>default-deploy</id>
- <phase>site-deploy</phase>
- <goals>
- <goal>deploy</goal>
- </goals>
- <configuration>
- <outputDirectory>E:My ProjectsJavaRegisterInfoMaventargetsite</outputDirectory>
- <reportPlugins>
- <reportPlugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-project-info-reports-plugin</artifactId>
- </reportPlugin>
- </reportPlugins>
- </configuration>
- </execution>
- </executions>
- <configuration>
- <outputDirectory>E:My ProjectsJavaRegisterInfoMaventargetsite</outputDirectory>
- <reportPlugins>
- <reportPlugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-project-info-reports-plugin</artifactId>
- </reportPlugin>
- </reportPlugins>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <reporting>
- <outputDirectory>E:My ProjectsJavaRegisterInfoMaventargetsite</outputDirectory>
- </reporting>
- </project>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement