moved apache tiles related code in spring-mvc-views module
This commit is contained in:
-47
@@ -1,47 +0,0 @@
|
||||
package com.baeldung.spring.configuration;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.ViewResolverRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
import org.springframework.web.servlet.view.tiles3.TilesConfigurer;
|
||||
import org.springframework.web.servlet.view.tiles3.TilesViewResolver;
|
||||
|
||||
@Configuration
|
||||
@EnableWebMvc
|
||||
@ComponentScan(basePackages = "com.baeldung.spring.controller.tiles")
|
||||
public class TilesApplicationConfiguration implements WebMvcConfigurer {
|
||||
|
||||
/**
|
||||
* Configure TilesConfigurer.
|
||||
*/
|
||||
@Bean
|
||||
public TilesConfigurer tilesConfigurer() {
|
||||
TilesConfigurer tilesConfigurer = new TilesConfigurer();
|
||||
tilesConfigurer.setDefinitions(new String[] { "/WEB-INF/views/**/tiles.xml" });
|
||||
tilesConfigurer.setCheckRefresh(true);
|
||||
return tilesConfigurer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure ViewResolvers to deliver views.
|
||||
*/
|
||||
@Override
|
||||
public void configureViewResolvers(ViewResolverRegistry registry) {
|
||||
TilesViewResolver viewResolver = new TilesViewResolver();
|
||||
registry.viewResolver(viewResolver);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure ResourceHandlers to serve static resources
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
registry.addResourceHandler("/static/**").addResourceLocations("/static/");
|
||||
}
|
||||
|
||||
}
|
||||
-2
@@ -23,8 +23,6 @@ public class WebInitializer implements WebApplicationInitializer {
|
||||
ctx.register(EmailConfiguration.class);
|
||||
// ctx.setServletContext(container);
|
||||
|
||||
//ctx.register(TilesApplicationConfiguration.class);
|
||||
|
||||
// Manage the lifecycle of the root application context
|
||||
container.addListener(new ContextLoaderListener(ctx));
|
||||
|
||||
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
package com.baeldung.spring.controller.tiles;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/")
|
||||
public class TilesController {
|
||||
|
||||
@RequestMapping(value = { "/" }, method = RequestMethod.GET)
|
||||
public String homePage(ModelMap model) {
|
||||
return "home";
|
||||
}
|
||||
|
||||
@RequestMapping(value = { "/apachetiles" }, method = RequestMethod.GET)
|
||||
public String productsPage(ModelMap model) {
|
||||
return "apachetiles";
|
||||
}
|
||||
|
||||
@RequestMapping(value = { "/springmvc" }, method = RequestMethod.GET)
|
||||
public String contactUsPage(ModelMap model) {
|
||||
return "springmvc";
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
<%@ 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>Apache Tiles</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Tiles with Spring MVC Demo</h2>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,25 +0,0 @@
|
||||
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
|
||||
pageEncoding="ISO-8859-1"%>
|
||||
<%@ page isELIgnored="false"%>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
|
||||
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
|
||||
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title><tiles:getAsString name="title" /></title>
|
||||
<link href="<c:url value='/static/css/app.css' />" rel="stylesheet"></link>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="flex-container">
|
||||
<tiles:insertAttribute name="header" />
|
||||
<tiles:insertAttribute name="menu" />
|
||||
<article class="article">
|
||||
<tiles:insertAttribute name="body" />
|
||||
</article>
|
||||
<tiles:insertAttribute name="footer" />
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,2 +0,0 @@
|
||||
|
||||
<footer>copyright © Baeldung</footer>
|
||||
@@ -1,3 +0,0 @@
|
||||
<header>
|
||||
<h1>Welcome to Spring MVC integration with Apache Tiles</h1>
|
||||
</header>
|
||||
@@ -1,8 +0,0 @@
|
||||
<nav class="nav">
|
||||
<a href="${pageContext.request.contextPath}/"></a>
|
||||
<ul id="menu">
|
||||
<li><a href="${pageContext.request.contextPath}/">Home</a></li>
|
||||
<li><a href="${pageContext.request.contextPath}/springmvc">SpringMVC</a></li>
|
||||
<li><a href="${pageContext.request.contextPath}/apachetiles">ApacheTiles</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
@@ -1,34 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE tiles-definitions PUBLIC "-//Apache Software Foundation//DTD Tiles Configuration 3.0//EN" "http://tiles.apache.org/dtds/tiles-config_3_0.dtd">
|
||||
|
||||
<tiles-definitions>
|
||||
|
||||
<!-- Template Definition -->
|
||||
<definition name="template-def"
|
||||
template="/WEB-INF/views/tiles/layouts/defaultLayout.jsp">
|
||||
<put-attribute name="title" value="" />
|
||||
<put-attribute name="header" value="/WEB-INF/views/tiles/templates/defaultHeader.jsp" />
|
||||
<put-attribute name="menu" value="/WEB-INF/views/tiles/templates/defaultMenu.jsp" />
|
||||
<put-attribute name="body" value="" />
|
||||
<put-attribute name="footer" value="/WEB-INF/views/tiles/templates/defaultFooter.jsp" />
|
||||
</definition>
|
||||
|
||||
<!-- Main Page -->
|
||||
<definition name="home" extends="template-def">
|
||||
<put-attribute name="title" value="Welcome" />
|
||||
<put-attribute name="body" value="/WEB-INF/views/pages/home.jsp" />
|
||||
</definition>
|
||||
|
||||
<!-- Apache Tiles Page -->
|
||||
<definition name="apachetiles" extends="template-def">
|
||||
<put-attribute name="title" value="ApacheTiles" />
|
||||
<put-attribute name="body" value="/WEB-INF/views/pages/apachetiles.jsp" />
|
||||
</definition>
|
||||
|
||||
<!-- Spring MVC Page -->
|
||||
<definition name="springmvc" extends="template-def">
|
||||
<put-attribute name="title" value="SpringMVC" />
|
||||
<put-attribute name="body" value="/WEB-INF/views/pages/springmvc.jsp" />
|
||||
</definition>
|
||||
|
||||
</tiles-definitions>
|
||||
Reference in New Issue
Block a user