Sie sind auf Seite 1von 31

Spring 3 MVC Tiles Plugin with Example

Posted by Dinesh Rajput


In this Chapter we will discuss about the tiles and build a simple Spring3MVC application that
utilizes templates using the Apache Tile 3 framework. Now we will create a template version of
our pages, and compare it with non-template versions of the same pages. We will split the
content, style, and template of these pages logically.

What is Apache Tiles 3.0.1?


Apache Tiles is a templating framework built to simplify the development of web application
user interfaces.
Apache Tiles is a popular and mostly used templating framework for java based web
application. Tiles became more popular because Struts 1.x uses Tiles as its default templating
framework. Spring3MVC which is an MVC framework, like Struts, also supports integration of
Tiles as its templating framework.
Tiles allows developer to define page fragments(or parts) which can be assembled into a
complete page at run-time. These fragments, or tiles, can be used as simple includes in order to
reduce the duplication of common page elements or embedded within other tiles to develop a
series of reusable templates. These templates streamline the development of a consistent look
and feel across an entire application.
Let us see how we can integrate Spring3MVC and Tiles.
You can download Tiles binaries from here

Application Layout

A web portal have many reusable templates like header, footer, menu etc. These elements
remains same in every web page to give a uniform feel and look to improve presentation of
portal. But difficult part is when you need to alter these common items.
The Tiles framework solve this problem by using templatization mechanism. We create a
common Header, Footer, Menu page and include this in each page. A common layout of website
is defined in a central configuration file and this layout can be extended across all the web pages
of the web application.
Add the following required tiles jars to WEB-INF/lib folder.

tiles-api-2.2.2.jar

tiles-core-2.2.2.jar

tiles-jsp-2.2.2.jar

tiles-servlet-2.2.2.jar

tiles-template-2.2.2.jar

In the previous chapter we run an application of CRUD operation on the Employee table using
Spring3MVC and Hibernate3. Now same we will build same application using tiles
configuration (or Tiles View Resolver) as view in stead of JstlView (or JSP View resolver).
Updated view of our application with using the tiles configuration look like as below diagram.

Application Structure:

EmployeeBean.java
view plainprint?

1.

package com.dineshonjava.bean;

2.
3.
4.

/**
* @author Dinesh Rajput

5.

6.

*/

7.

public class EmployeeBean {

8.

private Integer id;

9.

private String name;

10.

private Integer age;

11.

private Long salary;

12.

private String address;

13.
14.
15.

public Long getSalary() {


return salary;

16.

17.

public void setSalary(Long salary) {

18.

this.salary = salary;

19.

20.

public Integer getId() {

21.

return id;

22.

23.

public void setId(Integer id) {

24.

this.id = id;

25.

26.

public String getName() {

27.

return name;

28.

29.

public void setName(String name) {

30.
31.

this.name = name;
}

32.
33.

public Integer getAge() {


return age;

34.

35.

public void setAge(Integer age) {

36.

this.age = age;

37.

38.

public String getAddress() {

39.

return address;

40.

41.

public void setAddress(String address) {

42.
43.
44.

this.address = address;
}
}

Employee.java
view plainprint?

1.

package com.dineshonjava.model;

2.
3.

import java.io.Serializable;

4.
5.

import javax.persistence.Column;

6.

import javax.persistence.Entity;

7.

import javax.persistence.GeneratedValue;

8.

import javax.persistence.GenerationType;

9.

import javax.persistence.Id;

10.

import javax.persistence.Table;

11.
12.
13.

/**
* @author Dinesh Rajput

14.

15.

*/

16.

@Entity

17.

@Table(name="Employee")

18.

public class Employee implements Serializable{

19.
20.

private static final long serialVersionUID = -723583058586873479L;

21.
22.

@Id

23.

@GeneratedValue(strategy=GenerationType.AUTO)

24.

@Column(name = "empid")

25.

private Integer empId;

26.
27.

@Column(name="empname")

28.

private String empName;

29.
30.

@Column(name="empaddress")

31.

private String empAddress;

32.
33.

@Column(name="salary")

34.

private Long salary;

35.
36.

@Column(name="empAge")

37.

private Integer empAge;

38.
39.
40.

public Integer getEmpId() {


return empId;

41.

42.
43.
44.
45.

public void setEmpId(Integer empId) {


this.empId = empId;
}

46.
47.
48.
49.

public String getEmpName() {


return empName;
}

50.
51.
52.
53.

public void setEmpName(String empName) {


this.empName = empName;
}

54.
55.
56.
57.

public String getEmpAddress() {


return empAddress;
}

58.
59.
60.
61.

public void setEmpAddress(String empAddress) {


this.empAddress = empAddress;
}

62.
63.
64.
65.

public Long getSalary() {


return salary;
}

66.
67.

public void setSalary(Long salary) {

68.
69.

this.salary = salary;
}

70.
71.
72.
73.

public Integer getEmpAge() {


return empAge;
}

74.
75.
76.
77.
78.

public void setEmpAge(Integer empAge) {


this.empAge = empAge;
}
}

EmployeeDao.java
view plainprint?

1.

package com.dineshonjava.dao;

2.
3.

import java.util.List;

4.
5.

import com.dineshonjava.model.Employee;

6.
7.

/**

8.

* @author Dinesh Rajput

9.

10.

*/

11.

public interface EmployeeDao {

12.
13.

public void addEmployee(Employee employee);

14.
15.

public List<Employee> listEmployeess();

16.
17.

public Employee getEmployee(int empid);

18.
19.
20.

public void deleteEmployee(Employee employee);


}

EmployeeDaoImpl.java
view plainprint?

1.

package com.dineshonjava.dao;

2.
3.

import java.util.List;

4.
5.

import org.hibernate.SessionFactory;

6.

import org.springframework.beans.factory.annotation.Autowired;

7.

import org.springframework.stereotype.Repository;

8.
9.

import com.dineshonjava.model.Employee;

10.
11.

/**

12.

* @author Dinesh Rajput

13.

14.

*/

15.

@Repository("employeeDao")

16.

public class EmployeeDaoImpl implements EmployeeDao {

17.
18.

@Autowired

19.

private SessionFactory sessionFactory;

20.
21.

public void addEmployee(Employee employee) {

22.
23.

sessionFactory.getCurrentSession().saveOrUpdate(employee);
}

24.
25.

@SuppressWarnings("unchecked")

26.

public List<Employee> listEmployeess() {

27.
list();
28.

return (List<Employee>) sessionFactory.getCurrentSession().createCriteria(Employee.class).

29.
30.
31.
32.

public Employee getEmployee(int empid) {


return (Employee) sessionFactory.getCurrentSession().get(Employee.class, empid);
}

33.
34.

public void deleteEmployee(Employee employee) {

35.
sessionFactory.getCurrentSession().createQuery("DELETE FROM Employee WHERE empid = "
+employee.getEmpId()).executeUpdate();
36.

37.

}<span style="color: #4c1130;"><b>

38.

</b></span>

EmployeeService.java
view plainprint?

1.

package com.dineshonjava.service;

2.
3.

import java.util.List;

4.
5.

import com.dineshonjava.model.Employee;

6.
7.
8.

/**
* @author Dinesh Rajput

9.

10.

*/

11.

public interface EmployeeService {

12.
13.

public void addEmployee(Employee employee);

14.
15.

public List<Employee> listEmployeess();

16.
17.

public Employee getEmployee(int empid);

18.
19.
20.

public void deleteEmployee(Employee employee);


}

EmployeeServiceImpl.java
view plainprint?

1.

package com.dineshonjava.service;

2.
3.

import java.util.List;

4.
5.

import org.springframework.beans.factory.annotation.Autowired;

6.

import org.springframework.stereotype.Service;

7.

import org.springframework.transaction.annotation.Propagation;

8.

import org.springframework.transaction.annotation.Transactional;

9.
10.

import com.dineshonjava.dao.EmployeeDao;

11.

import com.dineshonjava.model.Employee;

12.
13.
14.

/**
* @author Dinesh Rajput

15.

16.

*/

17.

@Service("employeeService")

18.

@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)

19.

public class EmployeeServiceImpl implements EmployeeService {

20.
21.

@Autowired

22.

private EmployeeDao employeeDao;

23.
24.

@Transactional(propagation = Propagation.REQUIRED, readOnly = false)

25.

public void addEmployee(Employee employee) {

26.
27.

employeeDao.addEmployee(employee);
}

28.
29.
30.
31.

public List<Employee> listEmployeess() {


return employeeDao.listEmployeess();
}

32.
33.

public Employee getEmployee(int empid) {

34.

return employeeDao.getEmployee(empid);

35.

36.
37.
38.
39.

public void deleteEmployee(Employee employee) {


employeeDao.deleteEmployee(employee);
}

40.
41.

EmployeeController.java
view plainprint?

1.

package com.dineshonjava.controller;

2.
3.

import java.util.ArrayList;

4.

import java.util.HashMap;

5.

import java.util.List;

6.

import java.util.Map;

7.
8.

import org.springframework.beans.factory.annotation.Autowired;

9.

import org.springframework.stereotype.Controller;

10.

import org.springframework.validation.BindingResult;

11.

import org.springframework.web.bind.annotation.ModelAttribute;

12.

import org.springframework.web.bind.annotation.RequestMapping;

13.

import org.springframework.web.bind.annotation.RequestMethod;

14.

import org.springframework.web.servlet.ModelAndView;

15.
16.

import com.dineshonjava.bean.EmployeeBean;

17.

import com.dineshonjava.model.Employee;

18.

import com.dineshonjava.service.EmployeeService;

19.
20.

/**

21.

* @author Dinesh Rajput

22.

23.

*/

24.

@Controller

25.

public class EmployeeController {

26.
27.

@Autowired

28.

private EmployeeService employeeService;

29.
30.

@RequestMapping(value = "/save", method = RequestMethod.POST)

31.
ean,

public ModelAndView saveEmployee(@ModelAttribute("command")EmployeeBean employeeB

32.

BindingResult result) {

33.

Employee employee = prepareModel(employeeBean);

34.

employeeService.addEmployee(employee);

35.

return new ModelAndView("redirect:/add.html");

36.

37.
38.

@RequestMapping(value="/employees", method = RequestMethod.GET)

39.

public ModelAndView listEmployees() {

40.

Map<String, Object> model = new HashMap<String, Object>();

41.

model.put("employees", prepareListofBean(employeeService.listEmployeess()));

42.

return new ModelAndView("employeesList", model);

43.

44.
45.

@RequestMapping(value = "/add", method = RequestMethod.GET)

46.
ean,

public ModelAndView addEmployee(@ModelAttribute("command")EmployeeBean employeeB

47.

BindingResult result) {

48.

Map<String, Object> model = new HashMap<String, Object>();

49.

model.put("employees", prepareListofBean(employeeService.listEmployeess()));

50.

return new ModelAndView("addEmployee", model);

51.

52.
53.

@RequestMapping(value = "/index", method = RequestMethod.GET)

54.

public ModelAndView welcome() {

55.
56.

return new ModelAndView("redirect:/add.html");


}

57.
58.

@RequestMapping(value = "/delete", method = RequestMethod.GET)

59.
an,

public ModelAndView editEmployee(@ModelAttribute("command")EmployeeBean employeeBe

60.

BindingResult result) {

61.

employeeService.deleteEmployee(prepareModel(employeeBean));

62.

Map<String, Object> model = new HashMap<String, Object>();

63.

model.put("employee", null);

64.

model.put("employees", prepareListofBean(employeeService.listEmployeess()));

65.

return new ModelAndView("addEmployee", model);

66.

67.
68.

@RequestMapping(value = "/edit", method = RequestMethod.GET)

69.
Bean,

public ModelAndView deleteEmployee(@ModelAttribute("command")EmployeeBean employee

70.
71.

BindingResult result) {
Map<String, Object> model = new HashMap<String, Object>();

72.
model.put("employee", prepareEmployeeBean(employeeService.getEmployee(employeeBean
.getId())));
73.

model.put("employees", prepareListofBean(employeeService.listEmployeess()));

74.

return new ModelAndView("addEmployee", model);

75.
76.

77.

private Employee prepareModel(EmployeeBean employeeBean){

78.

Employee employee = new Employee();

79.

employee.setEmpAddress(employeeBean.getAddress());

80.

employee.setEmpAge(employeeBean.getAge());

81.

employee.setEmpName(employeeBean.getName());

82.

employee.setSalary(employeeBean.getSalary());

83.

employee.setEmpId(employeeBean.getId());

84.

employeeBean.setId(null);

85.

return employee;

86.

87.
88.

private List<EmployeeBean> prepareListofBean(List<Employee> employees){

89.

List<employeebean> beans = null;

90.

if(employees != null && !employees.isEmpty()){

91.

beans = new ArrayList<EmployeeBean>();

92.

EmployeeBean bean = null;

93.

for(Employee employee : employees){

94.

bean = new EmployeeBean();

95.

bean.setName(employee.getEmpName());

96.

bean.setId(employee.getEmpId());

97.

bean.setAddress(employee.getEmpAddress());

98.

bean.setSalary(employee.getSalary());

99.

bean.setAge(employee.getEmpAge());

100.

beans.add(bean);

101.

102.

103.

return beans;

104.

105.
106.

private EmployeeBean prepareEmployeeBean(Employee employee){

107.

EmployeeBean bean = new EmployeeBean();

108.

bean.setAddress(employee.getEmpAddress());

109.

bean.setAge(employee.getEmpAge());

110.

bean.setName(employee.getEmpName());

111.

bean.setSalary(employee.getSalary());

112.

bean.setId(employee.getEmpId());

113.

return bean;

114.
115.

}
}

Spring Web configuration file web.xml

view plainprint?
1. <web-app version="2.5" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xm
lns="http://java.sun.com/xml/ns/javaee" xsi:schemalocation="http://java.sun.com/xml/ns/
javaee
2.

http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

3.
4.

<servlet>

5.

<servlet-name>sdnext</servlet-name>

6.

<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>

7.

<init-param>

8.
9.
10.

<param-name>contextConfigLocation</param-name><param-value>/WEBINF/config/sdnext-servlet.xml</param-value></init-param>
<load-on-startup>1</load-on-startup>
</servlet>

11.
12. <servlet-mapping>
13. <servlet-name>sdnext</servlet-name>
14. <url-pattern>*.html</url-pattern>
15. </servlet-mapping>
16.
17. <welcome-file-list>
18. <welcome-file>index.html</welcome-file>
19. </welcome-file-list>
20.
21. </web-app>
Spring Web configuration file sdnext-servlet.xml
view plainprint?
1. <beans xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="htt
p://www.springframework.org/schema/tx" xmlns:xsi="http://www.w3.org/2001/XMLSch
ema-instance" xmlns="http://www.springframework.org/schema/beans" xsi:schemalocati
on="
2. http://www.springframework.org/schema/beans
3. http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
4. http://www.springframework.org/schema/context
5. http://www.springframework.org/schema/context/spring-context-3.0.xsd
6. http://www.springframework.org/schema/tx
7. http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
8.
9. <context:property-placeholder location="classpath:resources/database.properties">

10. </context:property-placeholder>
11. <context:component-scan base-package="com.dineshonjava">
12. </context:component-scan>
13.
14. <tx:annotation-driven transaction-manager="hibernateTransactionManager">
15. </tx:annotation-driven>
16.
17. <!-- <bean id="jspViewResolver"
18.

class="org.springframework.web.servlet.view.InternalResourceViewResolver">

19.

<property name="viewClass"

20.

value="org.springframework.web.servlet.view.JstlView"></property>

21.

<property name="prefix" value="/WEB-INF/views/"></property>

22.

<property name="suffix" value=".jsp"></property>

23. </bean> -->


24.
25. <bean class="org.springframework.web.servlet.view.UrlBasedViewResolver" id="viewR
esolver">
26.

<property name="viewClass">

27.

<value>

28.

org.springframework.web.servlet.view.tiles2.TilesView

29.

</value>

30.

</property>

31. </bean>

32. <bean class="org.springframework.web.servlet.view.tiles2.TilesConfigurer" id="tilesCon


figurer">
33.

<property name="definitions">

34.

<list>

35.

<value>/WEB-INF/config/tiles.xml</value>

36.

</list>

37.

</property>

38. </bean>
39.
40. <bean class="org.springframework.jdbc.datasource.DriverManagerDataSource" id="data
Source">
41. <property name="driverClassName" value="${database.driver}"></property>
42. <property name="url" value="${database.url}"></property>
43. <property name="username" value="${database.user}"></property>
44. <property name="password" value="${database.password}"></property>
45. </bean>
46.
47. <bean class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactory
Bean" id="sessionFactory">
48. <property name="dataSource" ref="dataSource"></property>
49. <property name="annotatedClasses">
50. <list>
51.

<value>com.dineshonjava.model.Employee</value>

52. </list>
53. </property>

54. <property name="hibernateProperties">


55. <props>
56. <prop key="hibernate.dialect">${hibernate.dialect}</prop>
57. <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
58. <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto} </prop>
59.

</props>

60.

</property>

61. </bean>
62.
63. <bean class="org.springframework.orm.hibernate3.HibernateTransactionManager" id="
hibernateTransactionManager">
64. <property name="sessionFactory" ref="sessionFactory"></property>
65. </bean>
66. </beans>
tiles.xml
view plainprint?
1. <tiles-definitions>
2.
3.
4.

<definition name="base.definition" template="/WEB-INF/views/mainTemplate.jsp">


<put-attribute name="title" value=""></put-attribute>
<put-attribute name="header" value="/WEB-INF/views/header.jsp"></putattribute>

5.

<put-attribute name="menu" value="/WEB-INF/views/menu.jsp"></put-attribute>

6.

<put-attribute name="body" value=""></put-attribute>

7.

<put-attribute name="footer" value="/WEB-INF/views/footer.jsp"></put-attribute>

8.

</definition>

9.
10.

<definition extends="base.definition" name="addEmployee">

11.

<put-attribute name="title" value="Employee Data Form"></put-attribute>

12.

<put-attribute name="body" value="/WEB-INF/views/addEmployee.jsp"></putattribute>

13.

</definition>

14.
15.

<definition extends="base.definition" name="employeesList">

16.
17.
18.

<put-attribute name="title" value="Employees List"></put-attribute>


<put-attribute name="body" value="/WEB-INF/views/employeesList.jsp"></putattribute>
</definition>

19.
20. </tiles-definitions>
database.properties
view plainprint?
1. database.driver=com.mysql.jdbc.Driver
2. database.url=jdbc:mysql://localhost:3306/DAVDB
3. database.user=root
4. database.password=root
5. hibernate.dialect=org.hibernate.dialect.MySQLDialect
6. hibernate.show_sql=true
7. hibernate.hbm2ddl.auto=update
addEmployee.jsp
view plainprint?

1.

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"

2.

pageEncoding="ISO-8859-1"%>

3.

<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>

4.

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

5.
6.
7.

<html>
<head>

8.
9.

<title>Spring MVC Form Handling</title>

10.

</head>

11.

<body>

12.
13.
14.

<h2>Add Employee Data</h2>


<form:form action="/sdnext/save.html" method="POST">
<table>

15.

<tbody>

16.

<tr>

17.

<td><form:label path="id">Employee ID:</form:label></td>

18.

<td><form:input path="id" readonly="true" value="${employee.id}">

19.

</form:input></td>

20.

</tr>

21.

<tr>

22.
23.
24.

<td><form:label path="name">Employee Name:</form:label></td>


<td><form:input path="name" value="${employee.name}">
</form:input></td>

25.

</tr>

26.

<tr>

27.

<td><form:label path="age">Employee Age:</form:label></td>

28.

<td><form:input path="age" value="${employee.age}">

29.

</form:input></td>

30.

</tr>

31.

<tr>

32.

<td><form:label path="salary">Employee Salary:</form:label></td>

33.

<td><form:input path="salary" value="${employee.salary}">

34.

</form:input></td>

35.

</tr>

36.

<tr>

37.

<td><form:label path="address">Employee Address:</form:label></td>

38.

<td><form:input path="address" value="${employee.address}">

39.

</form:input></td>

40.

</tr>

41.

<tr>

42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.

<td colspan="2">
<input type="submit" value="Submit"></td>
</tr>
</tbody>
</table>
</form:form>
<c:if test="${!empty employees}">
<h2> List Employees</h2>
<table align="left" border="1">
<tbody>
<tr>

53.

<th>Employee ID</th>

54.

<th>Employee Name</th>

55.

<th>Employee Age</th>

56.

<th>Employee Salary</th>

57.

<th>Employee Address</th>

58.

<th>Actions on Row</th>

59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.

</tr>
<c:foreach items="${employees}" var="employee">
<tr>
<td><c:out value="${employee.id}"></c:out>
</td>
<td><c:out value="${employee.name}"></c:out>
</td>
<td><c:out value="${employee.age}"></c:out>
</td>
<td><c:out value="${employee.salary}"></c:out>
</td>
<td><c:out value="${employee.address}"></c:out>
</td>

72.

<td align="center"><a href="edit.html/?id=${employee.id}">Edit</a> |

73.

<a href="delete.html/?id=${employee.id}">Delete</a>

74.

</td>

75.

</tr>

76.

</c:foreach>

77.
78.

</tbody></table>

79.

</c:if>

80.
81.

</body>
</html>

employeesList.jsp
view plainprint?

1.
2.
3.

<%@ 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"%>

4.
5.

<html>

6.

<head>

7.

<title>All Employees</title>

8.

</head>

9.

<body>

10.

<h1>

11.

List Employees</h1>

12.

<h3>

13.

<a href="http://add.html/">Add More Employee</a></h3>

14.

<c:if test="${!empty employees}">

15.
16.

<table align="left" border="1">

17.

<tbody>

18.

<tr>

19.

<th>Employee ID</th>

20.

<th>Employee Name</th>

21.

<th>Employee Age</th>

22.

<th>Employee Salary</th>

23.

<th>Employee Address</th>

24.

</tr>

25.

<c:foreach items="${employees}" var="employee">

26.

<tr>

27.

<td><c:out value="${employee.id}"></c:out>

28.

</td>

29.
30.

<td><c:out value="${employee.name}"></c:out>
</td>

31.
32.

<td><c:out value="${employee.age}"></c:out>
</td>

33.
34.

<td><c:out value="${employee.salary}"></c:out>
</td>

35.
36.

<td><c:out value="${employee.address}"></c:out></td>
</tr>

37.

</c:foreach>

38.

</tbody>

39.

</table>

40.

</c:if>

41.

</body>

42.

</html>

menu.jsp
view plainprint?

1.

<h2> Menu</h2>

2.

1. <a href="employees.html">List of Employees</a>

3.

2. <a href="add.html">Add Employee</a>

header.jsp
view plainprint?

1.

<h2>Header- Employee Management System</h2>

footer.jsp
view plainprint?

1.
2.

<p>Copyright &copy; 2013 dineshonjava.com</p>

mainTemplate.jsp
view plainprint?

1.
2.

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"


pageEncoding="ISO-8859-1"%>

3.
4.
5.

<html>
<head>

6.
7.

<title>
<tiles:insertAttribute name="title" ignore="true"></tiles:insertAttribute>
</title>
</head>
<body>
<table border="1" cellpadding="2" cellspacing="2" align="left">
<tr>
<td colspan="2" align="center">
<tiles:insertAttribute name="header"></tiles:insertAttribute>
</td>
</tr>
<tr>
<td>
<tiles:insertAttribute name="menu"></tiles:insertAttribute>
</td>
<td>
<tiles:insertAttribute name="body"></tiles:insertAttribute>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<tiles:insertAttribute name="footer"></tiles:insertAttribute>
</td>
</tr>
</table>
8.

</body>

9.

</html>

Once you are done with creating source and configuration files, export your application. Right click on
your application and use Export-> WAR File option and save your Spring3TilesApp.war file in Tomcat's
webapps folder.
Now start your Tomcat server and make sure you are able to access other web pages from webapps
folder using a standard browser. Now try a URL http://localhost:8080/sdnext/ and you should see the
following result if everything is fine with your Spring Web Application:

Now we click on the List of Employee link on the Menu section then we get the following output screen
we observe that only body of the mainTemplate is refreshed.

Dwonload this Application SourceCode+Libs


Spring3TilesApp.zip

Das könnte Ihnen auch gefallen