Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- dispatcher
- <?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:context="http://www.springframework.org/schema/context"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
- http://www.springframework.org/schema/context
- http://www.springframework.org/schema/context/spring-context-3.0.xsd">
- <context:component-scan base-package="com.athlete.controller"/>
- <bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
- <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
- <property name="prefix" value="/WEB-INF/views/" />
- <property name="suffix" value=".jsp" />
- </bean>
- <bean id="ds" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
- <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
- <property name="url" value="jdbc:oracle:thin:@localhost:1521:XE"/>
- <property name="username" value="hr"/>
- <property name="password" value="hr"/>
- </bean>
- <bean id="template" class="org.springframework.jdbc.core.JdbcTemplate">
- <property name="dataSource" ref="ds" />
- </bean>
- <bean id="athleteDao" class="com.athlete.dao.AthleteDao">
- <property name="jdbcTemplate" ref="template"/>
- </bean>
- </beans>
- //////////////////////////////////////////////////////////////////////////////////
- AthleteRowMapper
- package com.athlete.mapper;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import org.springframework.jdbc.core.RowMapper;
- import com.athlete.dto.AthleteInfo;;
- public class AthleteRowMapper implements RowMapper<AthleteInfo> {
- @Override
- public AthleteInfo mapRow(ResultSet resultSet, int id) throws SQLException {
- AthleteInfo AthleteInfo = new AthleteInfo();
- System.out.println("AthleteInfoRowMapper called ... ");
- AthleteInfo.setId(resultSet.getInt(1));
- AthleteInfo.setName(resultSet.getString(2));
- AthleteInfo.setGender(resultSet.getString(3));
- AthleteInfo.setCategory(resultSet.getString(4));
- AthleteInfo.setEmail(resultSet.getString(5));
- AthleteInfo.setMobile(resultSet.getInt(6));
- return AthleteInfo;
- }
- }
- ///////////////////////////////////////////////////////////////////////////////////////////
- client.jsp
- <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
- pageEncoding="ISO-8859-1"%>
- <!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=ISO-8859-1">
- <title>Insert title here</title>
- </style>
- </head>
- <body>
- </style>
- <H2>Athletes Registration System</H2>
- <a href="addinfo.do">Add an Athlete</a>
- <br />
- <a href="displayall.do">Show all Athletes Detail</a>
- </body>
- </html>
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- displayathletes.jsp
- <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
- pageEncoding="ISO-8859-1"%>
- <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
- <!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=ISO-8859-1">
- <title>Insert title here</title>
- <style>
- th, td {
- padding: 5px;
- text-align: centre;
- }</style>
- </head>
- <body>
- <table border="2" cellpadding="5px" cellspacing="5px" align="center">
- <th colspan="6"> Athletics Registration System</th>
- <tr>
- <td>Athlete Id</td>
- <td>Athlete Name</td>
- <td>Gender</td>
- <td>Category</td>
- <td>Email</td>
- <td>Mobile</td>
- </tr>
- <c:forEach var="athlete" items="${athletes}">
- <tr>
- <td><c:out value="${athlete.getId() }"></c:out>
- </td>
- <td><c:out value="${athlete.getName() }"></c:out>
- </td>
- <td><c:out value="${athlete.getGender() }"></c:out>
- </td>
- <td><c:out value="${athlete.getCategory() }"></c:out>
- </td>
- <td><c:out value="${athlete.getEmail() }"></c:out>
- </td>
- <td><c:out value="${athlete.getMobile() }"></c:out>
- </td>
- </tr>
- </c:forEach>
- </table>
- </body>
- </html>
Add Comment
Please, Sign In to add comment