From 5365a4f94603204ae695181aac091e951902ed82 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Wed, 26 Feb 2014 01:13:22 +0100 Subject: [PATCH] =?utf8?q?Die=20Basis=20f=C3=BCr=20die=20contextrelativen?= =?utf8?q?=20URL's=20wird=20jetzt=20Applicationweit=20bestimmt?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Zuvor wurde das Attribut "base" in jedem Template mithilfe des Tags aus der Spring-Taglib bestimmt. Jetzt wird das Attribut beim Start der Webanwendung einmalig bestimmt und im Application-Scope abgelegt. Das hat den Vorteil, dass das Attribut in abgeleiteten Webanwendungen, die die Templates wiederverwenden gezielt anders gesetzt werden kann. --- .../juplo/branding/web/ApplicationConfig.java | 22 +++++++++++++++++++ src/main/webapp/WEB-INF/404.jsp | 2 -- src/main/webapp/WEB-INF/error.jsp | 2 -- src/main/webapp/WEB-INF/spring/mvc.xml | 6 +++++ src/main/webapp/WEB-INF/templates/about.jsp | 2 -- src/main/webapp/WEB-INF/templates/footer.jsp | 2 -- src/main/webapp/WEB-INF/templates/header.jsp | 2 -- .../webapp/WEB-INF/templates/html-head.jsp | 2 -- .../webapp/WEB-INF/templates/html5page.jsp | 2 -- .../webapp/WEB-INF/templates/maincontent.jsp | 2 -- .../webapp/WEB-INF/templates/navigation.jsp | 2 -- .../WEB-INF/templates/test/breadcrumb.jsp | 2 -- .../WEB-INF/templates/test/experimente.jsp | 2 -- .../WEB-INF/templates/test/navigation.jsp | 2 -- src/main/webapp/WEB-INF/views/about.jsp | 2 -- .../WEB-INF/views/about/professions.jsp | 2 -- .../webapp/WEB-INF/views/about/references.jsp | 2 -- src/main/webapp/WEB-INF/views/blog.jsp | 2 -- .../webapp/WEB-INF/views/blog/article.jsp | 2 -- .../webapp/WEB-INF/views/blog/comments.jsp | 2 -- src/main/webapp/WEB-INF/views/contact.jsp | 2 -- src/main/webapp/WEB-INF/views/impressum.jsp | 2 -- .../WEB-INF/views/impressum/datenschutz.jsp | 2 -- .../views/impressum/google-analytics.jsp | 2 -- .../views/impressum/haftung-inhalte.jsp | 2 -- .../WEB-INF/views/impressum/haftung-links.jsp | 2 -- .../WEB-INF/views/impressum/urheberrechte.jsp | 2 -- src/main/webapp/WEB-INF/views/index.jsp | 2 -- src/main/webapp/WEB-INF/views/projects.jsp | 2 -- .../webapp/WEB-INF/views/projects/fix-swf.jsp | 2 -- .../projects/fix-swf/getting-started.jsp | 2 -- .../views/projects/fix-swf/overview.jsp | 2 -- .../views/projects/html-experimente.jsp | 2 -- .../webapp/WEB-INF/views/projects/typo.jsp | 2 -- .../WEB-INF/views/test/basis-layout.jsp | 2 -- .../WEB-INF/views/test/druck-layout.jsp | 2 -- src/main/webapp/WEB-INF/views/test/error.jsp | 2 -- ...-kein-men\303\274-aber-marginalinhalt.jsp" | 2 -- .../test/fast-leer-kein-men\303\274.jsp" | 2 -- ...er-mit-men\303\274-und-marginalinhalt.jsp" | 2 -- .../views/test/fast-leer-mit-men\303\274.jsp" | 2 -- .../webapp/WEB-INF/views/test/formulare.jsp | 2 -- .../webapp/WEB-INF/views/test/kein-layout.jsp | 2 -- src/main/webapp/WEB-INF/views/test/phone.jsp | 2 -- .../WEB-INF/views/test/seitenaufteilung.jsp | 2 -- .../webapp/WEB-INF/views/test/seitenkopf.jsp | 2 -- .../webapp/WEB-INF/views/test/symbole.jsp | 2 -- src/main/webapp/WEB-INF/views/test/tablet.jsp | 2 -- src/main/webapp/WEB-INF/views/test/tiny.jsp | 2 -- 49 files changed, 28 insertions(+), 94 deletions(-) create mode 100644 src/main/java/de/juplo/branding/web/ApplicationConfig.java diff --git a/src/main/java/de/juplo/branding/web/ApplicationConfig.java b/src/main/java/de/juplo/branding/web/ApplicationConfig.java new file mode 100644 index 00000000..598f1b08 --- /dev/null +++ b/src/main/java/de/juplo/branding/web/ApplicationConfig.java @@ -0,0 +1,22 @@ +package de.juplo.branding.web; + +import javax.annotation.PostConstruct; +import javax.annotation.Resource; +import javax.servlet.ServletContext; +import org.springframework.stereotype.Component; + + +@Component +public class ApplicationConfig +{ + public static final String ATTRIBUTE_BASE = "base"; + + @Resource + private ServletContext context; + + @PostConstruct + public void configureApplication() + { + context.setAttribute(ATTRIBUTE_BASE, context.getContextPath() + '/'); + } +} \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/404.jsp b/src/main/webapp/WEB-INF/404.jsp index 92187072..d826d417 100644 --- a/src/main/webapp/WEB-INF/404.jsp +++ b/src/main/webapp/WEB-INF/404.jsp @@ -3,8 +3,6 @@ <%@page session="false" %> <%@page isErrorPage="true" %> <%@taglib uri="http://tiles.apache.org/tags-tiles" prefix="t" %> -<%@taglib uri="http://www.springframework.org/tags" prefix="s"%> - diff --git a/src/main/webapp/WEB-INF/error.jsp b/src/main/webapp/WEB-INF/error.jsp index 5644494b..b6359a36 100644 --- a/src/main/webapp/WEB-INF/error.jsp +++ b/src/main/webapp/WEB-INF/error.jsp @@ -3,8 +3,6 @@ <%@page session="false" %> <%@page isErrorPage="true" %> <%@taglib uri="http://tiles.apache.org/tags-tiles" prefix="t" %> -<%@taglib uri="http://www.springframework.org/tags" prefix="s"%> - diff --git a/src/main/webapp/WEB-INF/spring/mvc.xml b/src/main/webapp/WEB-INF/spring/mvc.xml index cc5a0376..5fb88cf1 100644 --- a/src/main/webapp/WEB-INF/spring/mvc.xml +++ b/src/main/webapp/WEB-INF/spring/mvc.xml @@ -2,17 +2,23 @@ + + + diff --git a/src/main/webapp/WEB-INF/templates/about.jsp b/src/main/webapp/WEB-INF/templates/about.jsp index 2360f2f4..c4e44586 100644 --- a/src/main/webapp/WEB-INF/templates/about.jsp +++ b/src/main/webapp/WEB-INF/templates/about.jsp @@ -1,8 +1,6 @@ <%@page contentType="text/html;charset=UTF-8"%> <%@page pageEncoding="UTF-8"%> <%@page session="false" %> -<%@taglib uri="http://www.springframework.org/tags" prefix="s"%> -