Guest User

Untitled

a guest
Feb 2nd, 2018
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.33 KB | None | 0 0
  1. dispatcher
  2.  
  3. <?xml version="1.0" encoding="UTF-8"?>
  4. <beans xmlns="http://www.springframework.org/schema/beans"
  5. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  6. xmlns:context="http://www.springframework.org/schema/context"
  7. xsi:schemaLocation="http://www.springframework.org/schema/beans
  8. http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
  9. http://www.springframework.org/schema/context
  10. http://www.springframework.org/schema/context/spring-context-3.0.xsd">
  11.  
  12. <context:component-scan base-package="com.athlete.controller"/>
  13.  
  14. <bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
  15. <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
  16. <property name="prefix" value="/WEB-INF/views/" />
  17. <property name="suffix" value=".jsp" />
  18. </bean>
  19.  
  20. <bean id="ds" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
  21. <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
  22. <property name="url" value="jdbc:oracle:thin:@localhost:1521:XE"/>
  23. <property name="username" value="hr"/>
  24. <property name="password" value="hr"/>
  25. </bean>
  26.  
  27. <bean id="template" class="org.springframework.jdbc.core.JdbcTemplate">
  28. <property name="dataSource" ref="ds" />
  29. </bean>
  30.  
  31. <bean id="athleteDao" class="com.athlete.dao.AthleteDao">
  32. <property name="jdbcTemplate" ref="template"/>
  33. </bean>
  34.  
  35.  
  36. </beans>
  37. //////////////////////////////////////////////////////////////////////////////////
  38.  
  39.  
  40. AthleteRowMapper
  41.  
  42. package com.athlete.mapper;
  43.  
  44.  
  45. import java.sql.ResultSet;
  46. import java.sql.SQLException;
  47.  
  48. import org.springframework.jdbc.core.RowMapper;
  49.  
  50. import com.athlete.dto.AthleteInfo;;
  51.  
  52. public class AthleteRowMapper implements RowMapper<AthleteInfo> {
  53.  
  54. @Override
  55. public AthleteInfo mapRow(ResultSet resultSet, int id) throws SQLException {
  56. AthleteInfo AthleteInfo = new AthleteInfo();
  57. System.out.println("AthleteInfoRowMapper called ... ");
  58. AthleteInfo.setId(resultSet.getInt(1));
  59. AthleteInfo.setName(resultSet.getString(2));
  60. AthleteInfo.setGender(resultSet.getString(3));
  61. AthleteInfo.setCategory(resultSet.getString(4));
  62. AthleteInfo.setEmail(resultSet.getString(5));
  63. AthleteInfo.setMobile(resultSet.getInt(6));
  64. return AthleteInfo;
  65. }
  66.  
  67. }
  68. ///////////////////////////////////////////////////////////////////////////////////////////
  69. client.jsp
  70.  
  71. <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
  72. pageEncoding="ISO-8859-1"%>
  73. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  74. <html>
  75. <head>
  76.  
  77. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  78. <title>Insert title here</title>
  79.  
  80. </style>
  81. </head>
  82. <body>
  83.  
  84. </style>
  85. <H2>Athletes Registration System</H2>
  86. <a href="addinfo.do">Add an Athlete</a>
  87. <br />
  88. <a href="displayall.do">Show all Athletes Detail</a>
  89.  
  90. </body>
  91. </html>
  92. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  93.  
  94. displayathletes.jsp
  95.  
  96. <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
  97. pageEncoding="ISO-8859-1"%>
  98. <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
  99. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  100. <html>
  101. <head>
  102. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  103. <title>Insert title here</title>
  104. <style>
  105.  
  106. th, td {
  107. padding: 5px;
  108. text-align: centre;
  109. }</style>
  110. </head>
  111. <body>
  112. <table border="2" cellpadding="5px" cellspacing="5px" align="center">
  113.  
  114. <th colspan="6"> Athletics Registration System</th>
  115. <tr>
  116. <td>Athlete Id</td>
  117. <td>Athlete Name</td>
  118. <td>Gender</td>
  119. <td>Category</td>
  120. <td>Email</td>
  121. <td>Mobile</td>
  122. </tr>
  123. <c:forEach var="athlete" items="${athletes}">
  124. <tr>
  125. <td><c:out value="${athlete.getId() }"></c:out>
  126. </td>
  127. <td><c:out value="${athlete.getName() }"></c:out>
  128. </td>
  129. <td><c:out value="${athlete.getGender() }"></c:out>
  130. </td>
  131. <td><c:out value="${athlete.getCategory() }"></c:out>
  132. </td>
  133. <td><c:out value="${athlete.getEmail() }"></c:out>
  134. </td>
  135. <td><c:out value="${athlete.getMobile() }"></c:out>
  136. </td>
  137. </tr>
  138. </c:forEach>
  139.  
  140. </table>
  141. </body>
  142. </html>
Add Comment
Please, Sign In to add comment