Advertisement
Guest User

Untitled

a guest
Jan 11th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.98 KB | None | 0 0
  1. <%@page contentType="text/html" pageEncoding="UTF-8"%>
  2. <%@taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
  3. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  4. "http://www.w3.org/TR/html4/loose.dtd">
  5.  
  6. <html>
  7. <head>
  8. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  9. <title>Welcome to Spring Web MVC project</title>
  10. </head>
  11.  
  12. <body>
  13. <h1>Spring 3 Register!</h1>
  14. <a href="register.htm">click</a>
  15. <form:form action="${pageContext.request.contextPath}/register.htm" method="POST" modelAttribute="userForm">
  16. <table>
  17. <tr>
  18. <td colspan="2" align="center">Spring MVC Form Demo - Registration</td>
  19. </tr>
  20. <tr>
  21. <td>User Name</td>
  22. <td><form:input path="username" /></td>
  23. </tr>
  24. <tr>
  25. <td>Password</td>
  26. <td><form:password path="password" /></td>
  27. </tr>
  28. <tr>
  29. <td>Email</td>
  30. <td><form:input path="email" /></td>
  31. </tr>
  32. <tr>
  33. <td>BirthDate (mm/dd/yyyy)</td>
  34. <td><form:input path="birthDate" /></td>
  35. </tr>
  36. <tr>
  37. <td>Profession</td>
  38. <td><form:select path="profession" items="${professionList}" /></td>
  39. </tr>
  40. <tr>
  41. <td colspan="2" align="center"><input type="submit" value="Register" /></td>
  42. </tr>
  43.  
  44. </table>
  45. </form:form>
  46. </body>
  47. </html>
  48.  
  49. /*
  50. * To change this license header, choose License Headers in Project Properties.
  51. * To change this template file, choose Tools | Templates
  52. * and open the template in the editor.
  53. */
  54.  
  55. package RegisterInfo;
  56. import java.util.ArrayList;
  57. import java.util.List;
  58. import java.util.Map;
  59.  
  60. /**
  61. *
  62. * @author Harshit Shrivastava
  63. */
  64. import RegisterInfo.model.User;
  65.  
  66. import org.springframework.stereotype.Controller;
  67. import org.springframework.web.bind.annotation.ModelAttribute;
  68. import org.springframework.web.bind.annotation.RequestMapping;
  69. import org.springframework.web.bind.annotation.RequestMethod;
  70. import org.springframework.ui.Model;
  71.  
  72. @Controller
  73. @RequestMapping(value = "/register")
  74. public class RegistrationController {
  75.  
  76. @RequestMapping(method = RequestMethod.GET)
  77. public String viewRegistration(Model model)
  78. {
  79. User userForm = new User();
  80. model.addAttribute("userForm", new User());
  81.  
  82. /*List<String> professionList = new ArrayList();
  83. professionList.add("Developer");
  84. professionList.add("Designer");
  85. professionList.add("IT Manager");
  86. model.put("professionList", professionList);*/
  87. return "index";
  88. }
  89.  
  90. @RequestMapping(method = RequestMethod.POST)
  91. public String processRegistration(@ModelAttribute("userForm") User user, Map<String, Object> model)
  92. {
  93. System.out.println("Username : " + user.getUserName());
  94. model.put("userForm", new User());
  95. return "index";
  96. }
  97. }
  98.  
  99. /*
  100. * To change this license header, choose License Headers in Project Properties.
  101. * To change this template file, choose Tools | Templates
  102. * and open the template in the editor.
  103. */
  104.  
  105. package RegisterInfo.model;
  106.  
  107. /**
  108. *
  109. * @author Harshit Shrivastava
  110. */
  111. import java.util.Date;
  112.  
  113. public class User {
  114. private String username;
  115. private String password;
  116. private String email;
  117. private Date birthDate;
  118. private String profession;
  119.  
  120. public String getUserName()
  121. {
  122. return username;
  123. }
  124. public void setUserName(String username)
  125. {
  126. this.username = username;
  127. }
  128. public String getPassword()
  129. {
  130. return password;
  131. }
  132. public void setPassword(String password)
  133. {
  134. this.password = password;
  135. }
  136. public String getEmail()
  137. {
  138. return email;
  139. }
  140. public void setEmail(String email)
  141. {
  142. this.email = email;
  143. }
  144. public Date getBirthDate()
  145. {
  146. return birthDate;
  147. }
  148. public void setBirthDate(Date birthDate)
  149. {
  150. this.birthDate = birthDate;
  151. }
  152. public String getProfession()
  153. {
  154. return profession;
  155. }
  156. public void setProfession(String profession)
  157. {
  158. this.profession = profession;
  159. }
  160. }
  161.  
  162. <?xml version="1.0" encoding="UTF-8"?>
  163. <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">
  164. <context-param>
  165. <param-name>contextConfigLocation</param-name>
  166. <param-value>/WEB-INF/dispatcher-servlet.xml</param-value>
  167. </context-param>
  168. <listener>
  169. <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  170. </listener>
  171. <servlet>
  172. <servlet-name>dispatcher</servlet-name>
  173. <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  174. <load-on-startup>2</load-on-startup>
  175. </servlet>
  176. <servlet-mapping>
  177. <servlet-name>dispatcher</servlet-name>
  178. <url-pattern>/</url-pattern>
  179. </servlet-mapping>
  180. <session-config>
  181. <session-timeout>
  182. 30
  183. </session-timeout>
  184. </session-config>
  185. <welcome-file-list>
  186. <welcome-file>redirect.jsp</welcome-file>
  187. </welcome-file-list>
  188. </web-app>
  189.  
  190. <?xml version="1.0" encoding="UTF-8"?>
  191. <beans xmlns="http://www.springframework.org/schema/beans"
  192. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  193. xmlns:p="http://www.springframework.org/schema/p"
  194. xmlns:aop="http://www.springframework.org/schema/aop"
  195. xmlns:tx="http://www.springframework.org/schema/tx"
  196. xmlns:context="http://www.springframework.org/schema/context"
  197. xmlns:mvc="http://www.springframework.org/schema/mvc"
  198. xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
  199. http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
  200. http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
  201. http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
  202. http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd ">
  203.  
  204. <bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/>
  205.  
  206. <context:component-scan base-package="SpringRegister" />
  207. <mvc:annotation-driven />
  208. <!--
  209. Most controllers will use the ControllerClassNameHandlerMapping above, but
  210. for the index controller we are using ParameterizableViewController, so we must
  211. define an explicit mapping for it.
  212. -->
  213. <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
  214. <property name="mappings">
  215. <props>
  216. <prop key="index.htm">indexController</prop>
  217. </props>
  218. </property>
  219. </bean>
  220.  
  221. <bean id="viewResolver"
  222. class="org.springframework.web.servlet.view.InternalResourceViewResolver"
  223. p:prefix="/WEB-INF/jsp/"
  224. p:suffix=".jsp" />
  225.  
  226. <!--
  227. The index controller.
  228. -->
  229. <bean name="indexController"
  230. class="org.springframework.web.servlet.mvc.ParameterizableViewController"
  231. p:viewName="index" />
  232.  
  233. </beans>
  234.  
  235. <?xml version="1.0"?>
  236. <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"
  237. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  238. <modelVersion>4.0.0</modelVersion>
  239. <groupId>RegisterInfo</groupId>
  240. <artifactId>RegisterInfoMaven</artifactId>
  241. <version>1.0-SNAPSHOT</version>
  242. <packaging>war</packaging>
  243. <name>RegisterInfoMaven Maven Webapp</name>
  244. <url>http://maven.apache.org</url>
  245. <dependencies>
  246. <dependency>
  247. <groupId>junit</groupId>
  248. <artifactId>junit</artifactId>
  249. <version>3.8.1</version>
  250. <scope>test</scope>
  251. </dependency>
  252. </dependencies>
  253. <repositories>
  254. <repository>
  255. <snapshots>
  256. <enabled>false</enabled>
  257. </snapshots>
  258. <id>central</id>
  259. <name>Central Repository</name>
  260. <url>http://repo.maven.apache.org/maven2</url>
  261. </repository>
  262. </repositories>
  263. <pluginRepositories>
  264. <pluginRepository>
  265. <releases>
  266. <updatePolicy>never</updatePolicy>
  267. </releases>
  268. <snapshots>
  269. <enabled>false</enabled>
  270. </snapshots>
  271. <id>central</id>
  272. <name>Central Repository</name>
  273. <url>http://repo.maven.apache.org/maven2</url>
  274. </pluginRepository>
  275. </pluginRepositories>
  276. <build>
  277. <sourceDirectory>E:My ProjectsJavaRegisterInfoMavensrcmainjava</sourceDirectory>
  278. <scriptSourceDirectory>E:My ProjectsJavaRegisterInfoMavensrcmainscripts</scriptSourceDirectory>
  279. <testSourceDirectory>E:My ProjectsJavaRegisterInfoMavensrctestjava</testSourceDirectory>
  280. <outputDirectory>E:My ProjectsJavaRegisterInfoMaventargetclasses</outputDirectory>
  281. <testOutputDirectory>E:My ProjectsJavaRegisterInfoMaventargettest-classes</testOutputDirectory>
  282. <resources>
  283. <resource>
  284. <directory>E:My ProjectsJavaRegisterInfoMavensrcmainresources</directory>
  285. </resource>
  286. </resources>
  287. <testResources>
  288. <testResource>
  289. <directory>E:My ProjectsJavaRegisterInfoMavensrctestresources</directory>
  290. </testResource>
  291. </testResources>
  292. <directory>E:My ProjectsJavaRegisterInfoMaventarget</directory>
  293. <finalName>RegisterInfoMaven</finalName>
  294. <pluginManagement>
  295. <plugins>
  296. <plugin>
  297. <artifactId>maven-antrun-plugin</artifactId>
  298. <version>1.3</version>
  299. </plugin>
  300. <plugin>
  301. <artifactId>maven-assembly-plugin</artifactId>
  302. <version>2.2-beta-5</version>
  303. </plugin>
  304. <plugin>
  305. <artifactId>maven-dependency-plugin</artifactId>
  306. <version>2.1</version>
  307. </plugin>
  308. <plugin>
  309. <artifactId>maven-release-plugin</artifactId>
  310. <version>2.0</version>
  311. </plugin>
  312. </plugins>
  313. </pluginManagement>
  314. <plugins>
  315. <plugin>
  316. <artifactId>maven-clean-plugin</artifactId>
  317. <version>2.4.1</version>
  318. <executions>
  319. <execution>
  320. <id>default-clean</id>
  321. <phase>clean</phase>
  322. <goals>
  323. <goal>clean</goal>
  324. </goals>
  325. </execution>
  326. </executions>
  327. </plugin>
  328. <plugin>
  329. <artifactId>maven-install-plugin</artifactId>
  330. <version>2.3.1</version>
  331. <executions>
  332. <execution>
  333. <id>default-install</id>
  334. <phase>install</phase>
  335. <goals>
  336. <goal>install</goal>
  337. </goals>
  338. </execution>
  339. </executions>
  340. </plugin>
  341. <plugin>
  342. <artifactId>maven-resources-plugin</artifactId>
  343. <version>2.5</version>
  344. <executions>
  345. <execution>
  346. <id>default-resources</id>
  347. <phase>process-resources</phase>
  348. <goals>
  349. <goal>resources</goal>
  350. </goals>
  351. </execution>
  352. <execution>
  353. <id>default-testResources</id>
  354. <phase>process-test-resources</phase>
  355. <goals>
  356. <goal>testResources</goal>
  357. </goals>
  358. </execution>
  359. </executions>
  360. </plugin>
  361. <plugin>
  362. <artifactId>maven-surefire-plugin</artifactId>
  363. <version>2.10</version>
  364. <executions>
  365. <execution>
  366. <id>default-test</id>
  367. <phase>test</phase>
  368. <goals>
  369. <goal>test</goal>
  370. </goals>
  371. </execution>
  372. </executions>
  373. </plugin>
  374. <plugin>
  375. <artifactId>maven-compiler-plugin</artifactId>
  376. <version>2.3.2</version>
  377. <executions>
  378. <execution>
  379. <id>default-testCompile</id>
  380. <phase>test-compile</phase>
  381. <goals>
  382. <goal>testCompile</goal>
  383. </goals>
  384. </execution>
  385. <execution>
  386. <id>default-compile</id>
  387. <phase>compile</phase>
  388. <goals>
  389. <goal>compile</goal>
  390. </goals>
  391. </execution>
  392. </executions>
  393. </plugin>
  394. <plugin>
  395. <artifactId>maven-war-plugin</artifactId>
  396. <version>2.1.1</version>
  397. <executions>
  398. <execution>
  399. <id>default-war</id>
  400. <phase>package</phase>
  401. <goals>
  402. <goal>war</goal>
  403. </goals>
  404. </execution>
  405. </executions>
  406. </plugin>
  407. <plugin>
  408. <artifactId>maven-deploy-plugin</artifactId>
  409. <version>2.7</version>
  410. <executions>
  411. <execution>
  412. <id>default-deploy</id>
  413. <phase>deploy</phase>
  414. <goals>
  415. <goal>deploy</goal>
  416. </goals>
  417. </execution>
  418. </executions>
  419. </plugin>
  420. <plugin>
  421. <artifactId>maven-site-plugin</artifactId>
  422. <version>3.0</version>
  423. <executions>
  424. <execution>
  425. <id>default-site</id>
  426. <phase>site</phase>
  427. <goals>
  428. <goal>site</goal>
  429. </goals>
  430. <configuration>
  431. <outputDirectory>E:My ProjectsJavaRegisterInfoMaventargetsite</outputDirectory>
  432. <reportPlugins>
  433. <reportPlugin>
  434. <groupId>org.apache.maven.plugins</groupId>
  435. <artifactId>maven-project-info-reports-plugin</artifactId>
  436. </reportPlugin>
  437. </reportPlugins>
  438. </configuration>
  439. </execution>
  440. <execution>
  441. <id>default-deploy</id>
  442. <phase>site-deploy</phase>
  443. <goals>
  444. <goal>deploy</goal>
  445. </goals>
  446. <configuration>
  447. <outputDirectory>E:My ProjectsJavaRegisterInfoMaventargetsite</outputDirectory>
  448. <reportPlugins>
  449. <reportPlugin>
  450. <groupId>org.apache.maven.plugins</groupId>
  451. <artifactId>maven-project-info-reports-plugin</artifactId>
  452. </reportPlugin>
  453. </reportPlugins>
  454. </configuration>
  455. </execution>
  456. </executions>
  457. <configuration>
  458. <outputDirectory>E:My ProjectsJavaRegisterInfoMaventargetsite</outputDirectory>
  459. <reportPlugins>
  460. <reportPlugin>
  461. <groupId>org.apache.maven.plugins</groupId>
  462. <artifactId>maven-project-info-reports-plugin</artifactId>
  463. </reportPlugin>
  464. </reportPlugins>
  465. </configuration>
  466. </plugin>
  467. </plugins>
  468. </build>
  469. <reporting>
  470. <outputDirectory>E:My ProjectsJavaRegisterInfoMaventargetsite</outputDirectory>
  471. </reporting>
  472. </project>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement