Skip to content
This repository has been archived by the owner on Dec 15, 2021. It is now read-only.

Commit

Permalink
Update project for SPR-7093
Browse files Browse the repository at this point in the history
  • Loading branch information
sdeleuze committed Jun 18, 2014
1 parent 79d8286 commit b3d5b07
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 71 deletions.
75 changes: 19 additions & 56 deletions SPR-7093/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>

<!-- CGLIB, required for @Configuration usage -->
<dependency>
Expand Down Expand Up @@ -103,75 +108,33 @@
</dependency>


<!-- Apache Tiles
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-jsp</artifactId>
<version>2.1.3</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging-api</artifactId>
</exclusion>
</exclusions>
<artifactId>tiles-extras</artifactId>
<version>3.0.3</version>
</dependency>
-->

<!-- JSR 303 with Hibernate Validator
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.7</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.1.0.Final</version>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity-tools</artifactId>
<version>2.0</version>
</dependency>
-->

<!-- Joda Time Library
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>1.6.2</version>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.4.1</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time-jsptags</artifactId>
<version>1.0.2</version>
<scope>runtime</scope>
</dependency>
-->

<!-- Apache Commons File Upload
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.0.1</version>
</dependency>
-->

<!-- Jackson JSON Processor
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.8.1</version>
</dependency>
-->

<!-- Rome Atom+RSS
<dependency>
<groupId>rome</groupId>
<artifactId>rome</artifactId>
<version>1.0</version>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.4.1</version>
</dependency>
-->

<!-- Test -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.springframework.issues;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
public class SampleController {

@RequestMapping(value = "/", method = RequestMethod.GET)
public String tiles(@ModelAttribute("model") ModelMap model) {
model.addAttribute("hello", "Hello World!");
return "index";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,21 @@

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.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.ViewResolutionRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.config.annotation.*;
import org.springframework.web.servlet.view.json.MappingJackson2JsonView;

@EnableWebMvc
@ComponentScan(basePackages="org.springframework.issues")
@Configuration
public class WebConfig extends WebMvcConfigurerAdapter {

@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/").setViewName("home");
}

@Override
public void configureViewResolution(ViewResolutionRegistry registry) {
registry.jsp();
//registry.jsp();
//registry.freemarker();
//registry.velocity();
registry.tiles().definition("/WEB-INF/tiles.xml");
//registry.contentNegotiating(new MappingJackson2JsonView());
}

}
5 changes: 5 additions & 0 deletions SPR-7093/src/main/webapp/WEB-INF/index.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<html>
<body>
${model.hello}
</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!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=UTF-8">
<title>Site</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>My First Web Application Using Spring MVC</title>
</head>
<body>
<h1>Home</h1>
${model.hello}
</body>
</html>
</html>

5 changes: 5 additions & 0 deletions SPR-7093/src/main/webapp/WEB-INF/index.vm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<html>
<body>
${model.hello}
</body>
</html>
9 changes: 9 additions & 0 deletions SPR-7093/src/main/webapp/WEB-INF/tiles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!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>

<definition name="index" template="/WEB-INF/tiles/template.jsp">
<put-attribute name="body" value="/WEB-INF/tiles/index.jsp" />
</definition>

</tiles-definitions>
1 change: 1 addition & 0 deletions SPR-7093/src/main/webapp/WEB-INF/tiles/index.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${model.hello}
8 changes: 8 additions & 0 deletions SPR-7093/src/main/webapp/WEB-INF/tiles/template.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles" %>
<html>
<body>
<div id="body">
<tiles:insertAttribute name="body" />
</div>
</body>
</html>

0 comments on commit b3d5b07

Please sign in to comment.