From 6046624ce5b6677c0cf899cd3e748af6de2e1c54 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Thu, 18 Jul 2013 17:05:19 -0400 Subject: [PATCH 01/31] Switch to Spring Framework 4.0.0.BUILD-SNAPSHOT --- pom.xml | 2 +- .../samples/mvc/async/DeferredResultController.java | 3 +-- src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml | 2 +- .../springframework/samples/mvc/data/DataControllerTests.java | 3 ++- .../samples/mvc/data/StandardArgumentsControllerTests.java | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index d25f71b99..9d42662ab 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ 1.0.0-BUILD-SNAPSHOT 1.6 - 3.2.0.RELEASE + 4.0.0.BUILD-SNAPSHOT 1.6.10 1.6.1 diff --git a/src/main/java/org/springframework/samples/mvc/async/DeferredResultController.java b/src/main/java/org/springframework/samples/mvc/async/DeferredResultController.java index b4851b925..51b8e6d6a 100644 --- a/src/main/java/org/springframework/samples/mvc/async/DeferredResultController.java +++ b/src/main/java/org/springframework/samples/mvc/async/DeferredResultController.java @@ -2,7 +2,6 @@ import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.PriorityBlockingQueue; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Controller; @@ -31,7 +30,7 @@ public class DeferredResultController { } @RequestMapping("/deferred-result/model-and-view") - public @ResponseBody DeferredResult deferredResultWithView() { + public DeferredResult deferredResultWithView() { DeferredResult result = new DeferredResult(); this.mavQueue.add(result); return result; diff --git a/src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml b/src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml index 83ee0bb0a..21630e518 100644 --- a/src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml +++ b/src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml @@ -10,7 +10,7 @@ - + diff --git a/src/test/java/org/springframework/samples/mvc/data/DataControllerTests.java b/src/test/java/org/springframework/samples/mvc/data/DataControllerTests.java index d2c0b1be3..887cacd8b 100644 --- a/src/test/java/org/springframework/samples/mvc/data/DataControllerTests.java +++ b/src/test/java/org/springframework/samples/mvc/data/DataControllerTests.java @@ -3,6 +3,7 @@ import static org.hamcrest.Matchers.startsWith; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import static org.springframework.test.web.servlet.setup.MockMvcBuilders.webAppContextSetup; @@ -46,7 +47,7 @@ public void pathVar() throws Exception { @Test public void matrixVar() throws Exception { - this.mockMvc.perform(get("/data/matrixvars;foo=bar/simple")) + this.mockMvc.perform(get("/data/matrixvars;foo=bar/simple")).andDo(print()) .andExpect(content().string("Obtained matrix variable 'foo=bar' from path segment 'matrixvars'")); } diff --git a/src/test/java/org/springframework/samples/mvc/data/StandardArgumentsControllerTests.java b/src/test/java/org/springframework/samples/mvc/data/StandardArgumentsControllerTests.java index 248da786b..5321b2d9b 100644 --- a/src/test/java/org/springframework/samples/mvc/data/StandardArgumentsControllerTests.java +++ b/src/test/java/org/springframework/samples/mvc/data/StandardArgumentsControllerTests.java @@ -25,7 +25,7 @@ public void setup() throws Exception { public void request() throws Exception { this.mockMvc.perform(get("/data/standard/request")) .andExpect(content().string(startsWith( - "request = org.springframework.test.web.servlet.request.Servlet3MockHttpServletRequest@"))); + "request = org.springframework.mock.web.MockHttpServletRequest@"))); } @Test From 02c9661660eddb0c5c98efa2cb47407cc2b6079d Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Mon, 25 Nov 2013 21:59:25 -0500 Subject: [PATCH 02/31] Upgrade to Java 1.7 and aspectj 1.7.4 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 9d42662ab..901e47ce1 100644 --- a/pom.xml +++ b/pom.xml @@ -8,9 +8,9 @@ war 1.0.0-BUILD-SNAPSHOT - 1.6 + 1.7 4.0.0.BUILD-SNAPSHOT - 1.6.10 + 1.7.4 1.6.1 From 97e99103ee2609c8cd229b44d8896194d2497fa1 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 17 Dec 2013 08:56:18 -0500 Subject: [PATCH 03/31] Upgrade to Spring Framework 4 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 901e47ce1..7fae091e7 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ 1.0.0-BUILD-SNAPSHOT 1.7 - 4.0.0.BUILD-SNAPSHOT + 4.0.0.RELEASE 1.7.4 1.6.1 From 5bb425ebaa29837580d0ca4429b2f46db49918b4 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Thu, 26 Dec 2013 20:33:36 -0500 Subject: [PATCH 04/31] Add maven jetty plugin --- pom.xml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7fae091e7..82ac61427 100644 --- a/pom.xml +++ b/pom.xml @@ -277,7 +277,17 @@ org.apache.tomcat.maven tomcat7-maven-plugin 2.0 - + + + org.eclipse.jetty + jetty-maven-plugin + 9.0.6.v20130930 + + + /${project.artifactId} + + + From 361adc124c05a8187b84f25e8a57550bb7d9f8e4 Mon Sep 17 00:00:00 2001 From: Rob Winch Date: Mon, 6 Jan 2014 14:58:58 -0600 Subject: [PATCH 05/31] Add CSRF protection --- pom.xml | 8 ++++++++ src/main/webapp/WEB-INF/spring/root-context.xml | 17 ++++++++++++++++- src/main/webapp/WEB-INF/views/fileupload.jsp | 7 ++++++- src/main/webapp/WEB-INF/views/home.jsp | 15 +++++++++++++++ src/main/webapp/WEB-INF/web.xml | 10 ++++++++++ 5 files changed, 55 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 82ac61427..04d7ad0e6 100644 --- a/pom.xml +++ b/pom.xml @@ -10,6 +10,7 @@ 1.7 4.0.0.RELEASE + 3.2.0.RELEASE 1.7.4 1.6.1 @@ -151,6 +152,13 @@ commons-io 2.0.1 + + + + org.springframework.security + spring-security-web + ${org.springframework.security-version} + diff --git a/src/main/webapp/WEB-INF/spring/root-context.xml b/src/main/webapp/WEB-INF/spring/root-context.xml index c38cdffdf..2c734abb4 100644 --- a/src/main/webapp/WEB-INF/spring/root-context.xml +++ b/src/main/webapp/WEB-INF/spring/root-context.xml @@ -4,5 +4,20 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans%20http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> - + + + + + + + + + diff --git a/src/main/webapp/WEB-INF/views/fileupload.jsp b/src/main/webapp/WEB-INF/views/fileupload.jsp index 182fabbbd..05534b222 100644 --- a/src/main/webapp/WEB-INF/views/fileupload.jsp +++ b/src/main/webapp/WEB-INF/views/fileupload.jsp @@ -14,7 +14,12 @@

See the org.springframework.samples.mvc.fileupload package for the @Controller code

-
+ + +

Form

diff --git a/src/main/webapp/WEB-INF/views/home.jsp b/src/main/webapp/WEB-INF/views/home.jsp index 54aecdca1..e7070f0f2 100644 --- a/src/main/webapp/WEB-INF/views/home.jsp +++ b/src/main/webapp/WEB-INF/views/home.jsp @@ -5,6 +5,13 @@ spring-mvc-showcase " rel="stylesheet" type="text/css" /> " rel="stylesheet" type="text/css"/> + + + +

">spring-mvc-showcase

@@ -627,6 +634,14 @@ $(document).ready(function() { return false; }); + // Include CSRF token as header in JQuery AJAX requests + // See http://docs.spring.io/spring-security/site/docs/3.2.x/reference/htmlsingle/#csrf-include-csrf-token-ajax + var token = $("meta[name='_csrf']").attr("content"); + var header = $("meta[name='_csrf_header']").attr("content"); + $(document).ajaxSend(function(e, xhr, options) { + xhr.setRequestHeader(header, token); + }); + }); diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml index fc2be7c1f..d30ed1778 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/main/webapp/WEB-INF/web.xml @@ -13,6 +13,16 @@ org.springframework.web.context.ContextLoaderListener + + + csrfFilter + org.springframework.web.filter.DelegatingFilterProxy + true + + + csrfFilter + /* + From c7b9162c061e135c081a28bf7fc209bb9a992cea Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Wed, 12 Feb 2014 15:21:00 -0500 Subject: [PATCH 06/31] Upgrade to Spring Framework 4.0.1 --- pom.xml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/pom.xml b/pom.xml index 04d7ad0e6..9201d7e16 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ 1.0.0-BUILD-SNAPSHOT 1.7 - 4.0.0.RELEASE + 4.0.1.RELEASE 3.2.0.RELEASE 1.7.4 1.6.1 @@ -138,7 +138,7 @@ joda-time joda-time - 1.6.2 + 2.3 @@ -191,7 +191,6 @@ 1.3 test - @@ -211,6 +210,7 @@ + ${project.artifactId} org.apache.maven.plugins @@ -286,16 +286,16 @@ tomcat7-maven-plugin 2.0 - - org.eclipse.jetty - jetty-maven-plugin - 9.0.6.v20130930 - - - /${project.artifactId} - - - + + org.eclipse.jetty + jetty-maven-plugin + 9.0.6.v20130930 + + + /${project.artifactId} + + + From 92f5393d6edb332f22d589e7448fd629b36a2b42 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Wed, 23 Apr 2014 12:59:29 -0400 Subject: [PATCH 07/31] Upgrade to 4.0.3 and rever code commited in error --- pom.xml | 2 +- .../mvc/messageconverters/MessageConvertersController.java | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 9201d7e16..e07772c0f 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ 1.0.0-BUILD-SNAPSHOT 1.7 - 4.0.1.RELEASE + 4.0.3.RELEASE 3.2.0.RELEASE 1.7.4 1.6.1 diff --git a/src/main/java/org/springframework/samples/mvc/messageconverters/MessageConvertersController.java b/src/main/java/org/springframework/samples/mvc/messageconverters/MessageConvertersController.java index 890790bf1..a2f88d26b 100644 --- a/src/main/java/org/springframework/samples/mvc/messageconverters/MessageConvertersController.java +++ b/src/main/java/org/springframework/samples/mvc/messageconverters/MessageConvertersController.java @@ -69,11 +69,8 @@ public class MessageConvertersController { } @RequestMapping(value="/json", method=RequestMethod.GET) - public ResponseEntity writeJson() { - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.TEXT_PLAIN); - return new ResponseEntity(new JavaBean("bar", "apple"), headers , HttpStatus.OK); -// return new JavaBean("bar", "apple"); + public @ResponseBody JavaBean writeJson() { + return new JavaBean("bar", "apple"); } // AtomFeedHttpMessageConverter (requires Rome on the classpath - useful for serving Atom feeds) From 8b056141b91fa760e53866596211daa08fdc7adc Mon Sep 17 00:00:00 2001 From: Sebastien Deleuze Date: Thu, 24 Jul 2014 17:05:49 +0200 Subject: [PATCH 08/31] Upgrade to Spring 4.1.0.RC1 and fix Jackson and Rome dependencies --- pom.xml | 16 ++++++++-------- .../MessageConvertersController.java | 10 +++------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/pom.xml b/pom.xml index e07772c0f..6fc64c53a 100644 --- a/pom.xml +++ b/pom.xml @@ -9,9 +9,9 @@ 1.0.0-BUILD-SNAPSHOT 1.7 - 4.0.3.RELEASE + 4.1.0.RC1 3.2.0.RELEASE - 1.7.4 + 1.8.1 1.6.1 @@ -110,16 +110,16 @@ - org.codehaus.jackson - jackson-mapper-asl - 1.8.1 + com.fasterxml.jackson.core + jackson-databind + 2.4.1 - net.java.dev.rome + com.rometools rome - 1.0.0 + 1.5.0 @@ -170,7 +170,7 @@ junit junit - 4.8.2 + 4.11 test diff --git a/src/main/java/org/springframework/samples/mvc/messageconverters/MessageConvertersController.java b/src/main/java/org/springframework/samples/mvc/messageconverters/MessageConvertersController.java index a2f88d26b..47da6ee95 100644 --- a/src/main/java/org/springframework/samples/mvc/messageconverters/MessageConvertersController.java +++ b/src/main/java/org/springframework/samples/mvc/messageconverters/MessageConvertersController.java @@ -2,10 +2,9 @@ import javax.validation.Valid; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; +import com.rometools.rome.feed.atom.Feed; +import com.rometools.rome.feed.rss.Channel; + import org.springframework.stereotype.Controller; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; @@ -15,9 +14,6 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; -import com.sun.syndication.feed.atom.Feed; -import com.sun.syndication.feed.rss.Channel; - @Controller @RequestMapping("/messageconverters") public class MessageConvertersController { From 845aa68a47c5d6809604caba72e0f89ed30231f0 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 19 Aug 2014 12:11:29 -0400 Subject: [PATCH 09/31] Upgrade to 4.1 RC2 --- pom.xml | 12 ++++++------ .../WEB-INF/spring/appServlet/servlet-context.xml | 11 ++++++----- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/pom.xml b/pom.xml index 6fc64c53a..0ba8e28c5 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ 1.0.0-BUILD-SNAPSHOT 1.7 - 4.1.0.RC1 + 4.1.0.RC2 3.2.0.RELEASE 1.8.1 1.6.1 @@ -38,7 +38,7 @@ org.aspectj aspectjrt ${org.aspectj-version} - + @@ -134,7 +134,7 @@ 4.1.0.Final - + joda-time joda-time @@ -146,7 +146,7 @@ commons-fileupload commons-fileupload 1.2.2 - + commons-io commons-io @@ -192,7 +192,7 @@ test - + org.springframework.maven.snapshot @@ -215,7 +215,7 @@ org.apache.maven.plugins maven-compiler-plugin - 2.3.2 + 2.3.2 ${java-version} ${java-version} diff --git a/src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml b/src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml index 21630e518..eb46e018b 100644 --- a/src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml +++ b/src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml @@ -3,14 +3,15 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:task="http://www.springframework.org/schema/task" - xsi:schemaLocation="http://www.springframework.org/schema/mvc%20http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd-http://www.springframework.org/schema/task%20http://www.springframework.org/schema/task/spring-task-3.2.xsd-http://www.springframework.org/schema/beans%20http://www.springframework.org/schema/beans/spring-beans-3.2.xsd"> + xsi:schemaLocation=" + http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd + http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> - + @@ -45,4 +46,4 @@ - \ No newline at end of file + From d52a95d609dda27f1fe9bf8bee42c90d23aea301 Mon Sep 17 00:00:00 2001 From: huguangju Date: Mon, 11 Aug 2014 21:27:54 +0800 Subject: [PATCH 10/31] Fix css download errors in brower console --- src/main/webapp/WEB-INF/views/home.jsp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/webapp/WEB-INF/views/home.jsp b/src/main/webapp/WEB-INF/views/home.jsp index e7070f0f2..8e0fe94f2 100644 --- a/src/main/webapp/WEB-INF/views/home.jsp +++ b/src/main/webapp/WEB-INF/views/home.jsp @@ -4,8 +4,10 @@ spring-mvc-showcase " rel="stylesheet" type="text/css" /> - " rel="stylesheet" type="text/css"/> - + " rel="stylesheet" type="text/css"/> + " rel="stylesheet" type="text/css"/> + " rel="stylesheet" type="text/css"/> + @@ -112,7 +112,7 @@ com.fasterxml.jackson.core jackson-databind - 2.4.1 + 2.5.3 From a30e404e00c17f8405bd3d81a6154c4432434456 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 23 Jan 2018 12:06:58 -0500 Subject: [PATCH 16/31] Update dependencies --- pom.xml | 158 ++++++++---------- src/main/resources/log4j.xml | 42 ----- src/main/resources/log4j2.xml | 14 ++ .../samples/mvc/data/DataControllerTests.java | 2 +- .../samples/mvc/form/FormControllerTests.java | 1 - .../MessageConvertersControllerTests.java | 1 - .../SimpleControllerRevisitedTests.java | 2 +- src/test/resources/log4j.xml | 41 ----- src/test/resources/log4j2-test.xml | 14 ++ 9 files changed, 99 insertions(+), 176 deletions(-) delete mode 100644 src/main/resources/log4j.xml create mode 100644 src/main/resources/log4j2.xml delete mode 100644 src/test/resources/log4j.xml create mode 100644 src/test/resources/log4j2-test.xml diff --git a/pom.xml b/pom.xml index f3bae982b..158df64a6 100644 --- a/pom.xml +++ b/pom.xml @@ -7,32 +7,33 @@ spring-mvc-showcase war 1.0.0-BUILD-SNAPSHOT + - 1.7 - 4.2.2.RELEASE - 4.0.1.RELEASE + 1.8 + 5.0.3.RELEASE 1.8.1 - 1.7.12 + org.springframework spring-context ${org.springframework-version} - - - - commons-logging - commons-logging - - org.springframework spring-webmvc ${org.springframework-version} + + + + org.springframework.security + spring-security-web + 5.0.0.RELEASE + + org.aspectj @@ -42,27 +43,14 @@ - org.slf4j - slf4j-api - ${org.slf4j-version} - - - org.slf4j - jcl-over-slf4j - ${org.slf4j-version} - runtime + org.apache.logging.log4j + log4j-core + LATEST - org.slf4j - slf4j-log4j12 - ${org.slf4j-version} - runtime - - - log4j - log4j - 1.2.16 - runtime + org.apache.logging.log4j + log4j-slf4j-impl + LATEST @@ -72,93 +60,80 @@ 1 - + - org.apache.tomcat - tomcat-servlet-api - 7.0.30 + javax.servlet + javax.servlet-api + 3.1.0 provided javax.servlet.jsp - jsp-api - 2.1 + javax.servlet.jsp-api + 2.3.2-b02 provided javax.servlet.jsp.jstl - jstl-api - 1.2 - - - javax.servlet - servlet-api - - - - - org.glassfish.web - jstl-impl - 1.2 - - - javax.servlet - servlet-api - - + javax.servlet.jsp.jstl-api + 1.2.1 com.fasterxml.jackson.core jackson-databind - 2.5.3 + 2.9.3 com.rometools rome - 1.5.0 + 1.9.0 javax.validation validation-api - 1.0.0.GA + 2.0.1.Final org.hibernate hibernate-validator - 4.1.0.Final + 6.0.7.Final - + + javax.el + javax.el-api + 3.0.1-b04 + + + org.glassfish + javax.el + 3.0.1-b08 + + joda-time joda-time - 2.3 + 2.9.9 commons-fileupload commons-fileupload - 1.2.2 + 1.3.3 commons-io commons-io - 2.0.1 + 2.5 - - - org.springframework.security - spring-security-web - ${org.springframework.security-version} - @@ -170,19 +145,19 @@ junit junit - 4.11 + 4.12 test - xmlunit - xmlunit - 1.2 + org.xmlunit + xmlunit-matchers + 2.5.1 test com.jayway.jsonpath json-path - 0.8.1 + 2.4.0 test @@ -192,30 +167,36 @@ test + - - org.springframework.maven.snapshot + Spring snapshot Spring Maven Snapshot Repository http://repo.spring.io/snapshot - false - true + + false + + + true + - - org.springframework.maven.milestone + Spring milestone Spring Maven Milestone Repository http://repo.spring.io/milestone - false + + false + + ${project.artifactId} org.apache.maven.plugins maven-compiler-plugin - 2.3.2 + 3.7.0 ${java-version} ${java-version} @@ -224,7 +205,7 @@ org.apache.maven.plugins maven-surefire-plugin - 2.12 + 2.20.1 **/*Tests.java @@ -252,10 +233,8 @@ org.codehaus.mojo aspectj-maven-plugin - - 1.2 + 1.11 - org.aspectj aspectjrt @@ -270,13 +249,14 @@ - compile - test-compile + compile + test-compile true + ${java-version} ${java-version} ${java-version} @@ -289,7 +269,7 @@ org.eclipse.jetty jetty-maven-plugin - 9.0.6.v20130930 + 9.4.8.v20171121 /${project.artifactId} diff --git a/src/main/resources/log4j.xml b/src/main/resources/log4j.xml deleted file mode 100644 index 5439a479f..000000000 --- a/src/main/resources/log4j.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/resources/log4j2.xml b/src/main/resources/log4j2.xml new file mode 100644 index 000000000..da5e62170 --- /dev/null +++ b/src/main/resources/log4j2.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/src/test/java/org/springframework/samples/mvc/data/DataControllerTests.java b/src/test/java/org/springframework/samples/mvc/data/DataControllerTests.java index 887cacd8b..4e31be891 100644 --- a/src/test/java/org/springframework/samples/mvc/data/DataControllerTests.java +++ b/src/test/java/org/springframework/samples/mvc/data/DataControllerTests.java @@ -47,7 +47,7 @@ public void pathVar() throws Exception { @Test public void matrixVar() throws Exception { - this.mockMvc.perform(get("/data/matrixvars;foo=bar/simple")).andDo(print()) + this.mockMvc.perform(get("/data/matrixvars;foo=bar/simple")) .andExpect(content().string("Obtained matrix variable 'foo=bar' from path segment 'matrixvars'")); } diff --git a/src/test/java/org/springframework/samples/mvc/form/FormControllerTests.java b/src/test/java/org/springframework/samples/mvc/form/FormControllerTests.java index c919e7159..b213d0aad 100644 --- a/src/test/java/org/springframework/samples/mvc/form/FormControllerTests.java +++ b/src/test/java/org/springframework/samples/mvc/form/FormControllerTests.java @@ -51,7 +51,6 @@ public void submitSuccess() throws Exception { .param("additionalInfo[java]", "true") .param("_additionalInfo[java]", "on") .param("subscribeNewsletter", "false")) - .andDo(print()) .andExpect(status().isMovedTemporarily()) .andExpect(redirectedUrl("/form")) .andExpect(flash().attribute("message", diff --git a/src/test/java/org/springframework/samples/mvc/messageconverters/MessageConvertersControllerTests.java b/src/test/java/org/springframework/samples/mvc/messageconverters/MessageConvertersControllerTests.java index fdab6b28c..650623392 100644 --- a/src/test/java/org/springframework/samples/mvc/messageconverters/MessageConvertersControllerTests.java +++ b/src/test/java/org/springframework/samples/mvc/messageconverters/MessageConvertersControllerTests.java @@ -95,7 +95,6 @@ public void writeJson() throws Exception { @Test public void writeJson2() throws Exception { this.mockMvc.perform(get(URI, "json").accept(MediaType.APPLICATION_JSON)) - .andDo(print()) .andExpect(jsonPath("$.foo").value("bar")) .andExpect(jsonPath("$.fruit").value("apple")); } diff --git a/src/test/java/org/springframework/samples/mvc/simple/SimpleControllerRevisitedTests.java b/src/test/java/org/springframework/samples/mvc/simple/SimpleControllerRevisitedTests.java index de0ec0622..a7c6d4d97 100644 --- a/src/test/java/org/springframework/samples/mvc/simple/SimpleControllerRevisitedTests.java +++ b/src/test/java/org/springframework/samples/mvc/simple/SimpleControllerRevisitedTests.java @@ -15,7 +15,7 @@ public void simple() throws Exception { standaloneSetup(new SimpleControllerRevisited()).build() .perform(get("/simple/revisited").accept(MediaType.TEXT_PLAIN)) .andExpect(status().isOk()) - .andExpect(content().contentType("text/plain")) + .andExpect(content().contentType("text/plain;charset=ISO-8859-1")) .andExpect(content().string("Hello world revisited!")); } diff --git a/src/test/resources/log4j.xml b/src/test/resources/log4j.xml deleted file mode 100644 index 7620a1676..000000000 --- a/src/test/resources/log4j.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/test/resources/log4j2-test.xml b/src/test/resources/log4j2-test.xml new file mode 100644 index 000000000..4014ced5b --- /dev/null +++ b/src/test/resources/log4j2-test.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + From cd984e50c466ba35a997a7b94f498b7534424a5d Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 23 Jan 2018 12:13:49 -0500 Subject: [PATCH 17/31] Polish --- .../samples/mvc/async/CallableController.java | 44 +++++++------------ .../mvc/async/DeferredResultController.java | 14 +++--- .../TimeoutCallableProcessingInterceptor.java | 2 +- .../data/custom/CustomArgumentResolver.java | 6 ++- .../mvc/fileupload/FileUploadController.java | 2 +- .../data/CustomArgumentControllerTests.java | 2 +- .../exceptions/ExceptionControllerTests.java | 2 +- .../samples/mvc/form/FormControllerTests.java | 2 +- .../mvc/mapping/MappingControllerTests.java | 2 +- .../mvc/redirect/RedirectControllerTests.java | 2 +- .../mvc/response/ResponseControllerTests.java | 13 +++--- .../validation/ValidationControllerTests.java | 12 ++--- .../mvc/views/ViewsControllerTests.java | 2 +- 13 files changed, 47 insertions(+), 58 deletions(-) diff --git a/src/main/java/org/springframework/samples/mvc/async/CallableController.java b/src/main/java/org/springframework/samples/mvc/async/CallableController.java index 4ea6ec86a..345e0d49d 100644 --- a/src/main/java/org/springframework/samples/mvc/async/CallableController.java +++ b/src/main/java/org/springframework/samples/mvc/async/CallableController.java @@ -29,15 +29,11 @@ public String call() throws Exception { @RequestMapping("/view") public Callable callableWithView(final Model model) { - - return new Callable() { - @Override - public String call() throws Exception { - Thread.sleep(2000); - model.addAttribute("foo", "bar"); - model.addAttribute("fruit", "apple"); - return "views/html"; - } + return () -> { + Thread.sleep(2000); + model.addAttribute("foo", "bar"); + model.addAttribute("fruit", "apple"); + return "views/html"; }; } @@ -45,32 +41,24 @@ public String call() throws Exception { public @ResponseBody Callable callableWithException( final @RequestParam(required=false, defaultValue="true") boolean handled) { - return new Callable() { - @Override - public String call() throws Exception { - Thread.sleep(2000); - if (handled) { - // see handleException method further below - throw new IllegalStateException("Callable error"); - } - else { - throw new IllegalArgumentException("Callable error"); - } + return () -> { + Thread.sleep(2000); + if (handled) { + // see handleException method further below + throw new IllegalStateException("Callable error"); + } + else { + throw new IllegalArgumentException("Callable error"); } }; } @RequestMapping("/custom-timeout-handling") public @ResponseBody WebAsyncTask callableWithCustomTimeoutHandling() { - - Callable callable = new Callable() { - @Override - public String call() throws Exception { - Thread.sleep(2000); - return "Callable result"; - } + Callable callable = () -> { + Thread.sleep(2000); + return "Callable result"; }; - return new WebAsyncTask(1000, callable); } diff --git a/src/main/java/org/springframework/samples/mvc/async/DeferredResultController.java b/src/main/java/org/springframework/samples/mvc/async/DeferredResultController.java index 51b8e6d6a..3fe83f87c 100644 --- a/src/main/java/org/springframework/samples/mvc/async/DeferredResultController.java +++ b/src/main/java/org/springframework/samples/mvc/async/DeferredResultController.java @@ -15,30 +15,30 @@ @RequestMapping("/async") public class DeferredResultController { - private final Queue> responseBodyQueue = new ConcurrentLinkedQueue>(); + private final Queue> responseBodyQueue = new ConcurrentLinkedQueue<>(); - private final Queue> mavQueue = new ConcurrentLinkedQueue>(); + private final Queue> mavQueue = new ConcurrentLinkedQueue<>(); - private final Queue> exceptionQueue = new ConcurrentLinkedQueue>(); + private final Queue> exceptionQueue = new ConcurrentLinkedQueue<>(); @RequestMapping("/deferred-result/response-body") public @ResponseBody DeferredResult deferredResult() { - DeferredResult result = new DeferredResult(); + DeferredResult result = new DeferredResult<>(); this.responseBodyQueue.add(result); return result; } @RequestMapping("/deferred-result/model-and-view") public DeferredResult deferredResultWithView() { - DeferredResult result = new DeferredResult(); + DeferredResult result = new DeferredResult<>(); this.mavQueue.add(result); return result; } @RequestMapping("/deferred-result/exception") public @ResponseBody DeferredResult deferredResultWithException() { - DeferredResult result = new DeferredResult(); + DeferredResult result = new DeferredResult<>(); this.exceptionQueue.add(result); return result; } @@ -49,7 +49,7 @@ public DeferredResult deferredResultWithView() { // Provide a default result in case of timeout and override the timeout value // set in src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml - return new DeferredResult(1000L, "Deferred result after timeout"); + return new DeferredResult<>(1000L, "Deferred result after timeout"); } @Scheduled(fixedRate=2000) diff --git a/src/main/java/org/springframework/samples/mvc/async/TimeoutCallableProcessingInterceptor.java b/src/main/java/org/springframework/samples/mvc/async/TimeoutCallableProcessingInterceptor.java index 5eee8c583..c5440d63c 100644 --- a/src/main/java/org/springframework/samples/mvc/async/TimeoutCallableProcessingInterceptor.java +++ b/src/main/java/org/springframework/samples/mvc/async/TimeoutCallableProcessingInterceptor.java @@ -8,7 +8,7 @@ public class TimeoutCallableProcessingInterceptor extends CallableProcessingInterceptorAdapter { @Override - public Object handleTimeout(NativeWebRequest request, Callable task) throws Exception { + public Object handleTimeout(NativeWebRequest request, Callable task) { throw new IllegalStateException("[" + task.getClass().getName() + "] timed out"); } diff --git a/src/main/java/org/springframework/samples/mvc/data/custom/CustomArgumentResolver.java b/src/main/java/org/springframework/samples/mvc/data/custom/CustomArgumentResolver.java index ed1b02fcc..59ba7fbf6 100644 --- a/src/main/java/org/springframework/samples/mvc/data/custom/CustomArgumentResolver.java +++ b/src/main/java/org/springframework/samples/mvc/data/custom/CustomArgumentResolver.java @@ -13,8 +13,10 @@ public boolean supportsParameter(MethodParameter parameter) { return parameter.getParameterAnnotation(RequestAttribute.class) != null; } - public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, - WebDataBinderFactory binderFactory) throws Exception { + public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, + NativeWebRequest webRequest, WebDataBinderFactory binderFactory) + throws Exception { + RequestAttribute attr = parameter.getParameterAnnotation(RequestAttribute.class); return webRequest.getAttribute(attr.value(), WebRequest.SCOPE_REQUEST); } diff --git a/src/main/java/org/springframework/samples/mvc/fileupload/FileUploadController.java b/src/main/java/org/springframework/samples/mvc/fileupload/FileUploadController.java index b7eda699d..4624a4878 100644 --- a/src/main/java/org/springframework/samples/mvc/fileupload/FileUploadController.java +++ b/src/main/java/org/springframework/samples/mvc/fileupload/FileUploadController.java @@ -26,7 +26,7 @@ public void fileUploadForm() { } @RequestMapping(method=RequestMethod.POST) - public void processUpload(@RequestParam MultipartFile file, Model model) throws IOException { + public void processUpload(@RequestParam MultipartFile file, Model model) { model.addAttribute("message", "File '" + file.getOriginalFilename() + "' uploaded successfully"); } diff --git a/src/test/java/org/springframework/samples/mvc/data/CustomArgumentControllerTests.java b/src/test/java/org/springframework/samples/mvc/data/CustomArgumentControllerTests.java index a0ab7d4e7..e8a9a5a78 100644 --- a/src/test/java/org/springframework/samples/mvc/data/CustomArgumentControllerTests.java +++ b/src/test/java/org/springframework/samples/mvc/data/CustomArgumentControllerTests.java @@ -14,7 +14,7 @@ public class CustomArgumentControllerTests { private MockMvc mockMvc; @Before - public void setup() throws Exception { + public void setup() { this.mockMvc = standaloneSetup(new CustomArgumentController()) .setCustomArgumentResolvers(new CustomArgumentResolver()).build(); } diff --git a/src/test/java/org/springframework/samples/mvc/exceptions/ExceptionControllerTests.java b/src/test/java/org/springframework/samples/mvc/exceptions/ExceptionControllerTests.java index 8a0ff4541..d7ac2f7d6 100644 --- a/src/test/java/org/springframework/samples/mvc/exceptions/ExceptionControllerTests.java +++ b/src/test/java/org/springframework/samples/mvc/exceptions/ExceptionControllerTests.java @@ -18,7 +18,7 @@ public class ExceptionControllerTests extends AbstractContextControllerTests { private MockMvc mockMvc; @Before - public void setup() throws Exception { + public void setup() { this.mockMvc = webAppContextSetup(this.wac).build(); } diff --git a/src/test/java/org/springframework/samples/mvc/form/FormControllerTests.java b/src/test/java/org/springframework/samples/mvc/form/FormControllerTests.java index b213d0aad..97992e323 100644 --- a/src/test/java/org/springframework/samples/mvc/form/FormControllerTests.java +++ b/src/test/java/org/springframework/samples/mvc/form/FormControllerTests.java @@ -24,7 +24,7 @@ public class FormControllerTests { private MockMvc mockMvc; @Before - public void setup() throws Exception { + public void setup() { InternalResourceViewResolver viewResolver = new InternalResourceViewResolver(); viewResolver.setPrefix("/WEB-INF/"); diff --git a/src/test/java/org/springframework/samples/mvc/mapping/MappingControllerTests.java b/src/test/java/org/springframework/samples/mvc/mapping/MappingControllerTests.java index 71b191546..861093fe2 100644 --- a/src/test/java/org/springframework/samples/mvc/mapping/MappingControllerTests.java +++ b/src/test/java/org/springframework/samples/mvc/mapping/MappingControllerTests.java @@ -23,7 +23,7 @@ public class MappingControllerTests extends AbstractContextControllerTests { private MockMvc mockMvc; @Before - public void setup() throws Exception { + public void setup() { this.mockMvc = webAppContextSetup(this.wac).alwaysExpect(status().isOk()).build(); } diff --git a/src/test/java/org/springframework/samples/mvc/redirect/RedirectControllerTests.java b/src/test/java/org/springframework/samples/mvc/redirect/RedirectControllerTests.java index cd710cf65..7798ee19e 100644 --- a/src/test/java/org/springframework/samples/mvc/redirect/RedirectControllerTests.java +++ b/src/test/java/org/springframework/samples/mvc/redirect/RedirectControllerTests.java @@ -17,7 +17,7 @@ public class RedirectControllerTests { @Before public void setup() throws Exception { this.mockMvc = standaloneSetup(new RedirectController(new DefaultFormattingConversionService())) - .alwaysExpect(status().isMovedTemporarily()).build(); + .alwaysExpect(status().isFound()).build(); } @Test diff --git a/src/test/java/org/springframework/samples/mvc/response/ResponseControllerTests.java b/src/test/java/org/springframework/samples/mvc/response/ResponseControllerTests.java index 0cf136244..89b5b647d 100644 --- a/src/test/java/org/springframework/samples/mvc/response/ResponseControllerTests.java +++ b/src/test/java/org/springframework/samples/mvc/response/ResponseControllerTests.java @@ -1,24 +1,23 @@ package org.springframework.samples.mvc.response; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standaloneSetup; - import java.nio.charset.Charset; import org.junit.Before; import org.junit.Test; + import org.springframework.http.MediaType; import org.springframework.test.web.servlet.MockMvc; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; +import static org.springframework.test.web.servlet.setup.MockMvcBuilders.*; + public class ResponseControllerTests { private MockMvc mockMvc; @Before - public void setup() throws Exception { + public void setup() { this.mockMvc = standaloneSetup(new ResponseController()).build(); } diff --git a/src/test/java/org/springframework/samples/mvc/validation/ValidationControllerTests.java b/src/test/java/org/springframework/samples/mvc/validation/ValidationControllerTests.java index a0b42b1a3..47bd522af 100644 --- a/src/test/java/org/springframework/samples/mvc/validation/ValidationControllerTests.java +++ b/src/test/java/org/springframework/samples/mvc/validation/ValidationControllerTests.java @@ -1,20 +1,20 @@ package org.springframework.samples.mvc.validation; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standaloneSetup; - import org.junit.Before; import org.junit.Test; + import org.springframework.test.web.servlet.MockMvc; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; +import static org.springframework.test.web.servlet.setup.MockMvcBuilders.*; + public class ValidationControllerTests { private MockMvc mockMvc; @Before - public void setup() throws Exception { + public void setup() { this.mockMvc = standaloneSetup(new ValidationController()).alwaysExpect(status().isOk()).build(); } diff --git a/src/test/java/org/springframework/samples/mvc/views/ViewsControllerTests.java b/src/test/java/org/springframework/samples/mvc/views/ViewsControllerTests.java index e69321f08..dc5864eb4 100644 --- a/src/test/java/org/springframework/samples/mvc/views/ViewsControllerTests.java +++ b/src/test/java/org/springframework/samples/mvc/views/ViewsControllerTests.java @@ -20,7 +20,7 @@ public class ViewsControllerTests extends AbstractContextControllerTests { private MockMvc mockMvc; @Before - public void setup() throws Exception { + public void setup() { this.mockMvc = webAppContextSetup(this.wac).alwaysExpect(status().isOk()).build(); } From b53082e9ae8ebd0f0477a5761eb6a6ab1203fea5 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 23 Jan 2018 12:26:23 -0500 Subject: [PATCH 18/31] Use out tag for success message Issue #26 --- src/main/webapp/WEB-INF/views/form.jsp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/webapp/WEB-INF/views/form.jsp b/src/main/webapp/WEB-INF/views/form.jsp index cf79829fb..dac22b582 100644 --- a/src/main/webapp/WEB-INF/views/form.jsp +++ b/src/main/webapp/WEB-INF/views/form.jsp @@ -20,7 +20,7 @@

Form

-
${message}
+
From 4543d0df37c7c0720d72e850ca23f3fdd8480de5 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 23 Jan 2018 12:29:39 -0500 Subject: [PATCH 19/31] Update README.md --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d0f5de48f..90f383f0b 100644 --- a/README.md +++ b/README.md @@ -35,10 +35,8 @@ From the command line with Maven: or -In your preferred IDE such as SpringSource Tool Suite (STS) or IDEA: - -* Import spring-mvc-showcase as a Maven Project -* Drag-n-drop the project onto the "SpringSource tc Server Developer Edition" or another Servlet 2.5 or > Server to run, such as Tomcat. + $ cd spring-mvc-showcase + $ mvn jetty:run Access the deployed web application at: http://localhost:8080/spring-mvc-showcase/ From 5903eed3fa318a3357c4f8176e72151d636cff2b Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 23 Jan 2018 13:01:34 -0500 Subject: [PATCH 20/31] Fix jstl issue introduced in recent depenency update --- pom.xml | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/pom.xml b/pom.xml index 158df64a6..b0ffff80a 100644 --- a/pom.xml +++ b/pom.xml @@ -74,9 +74,9 @@ provided - javax.servlet.jsp.jstl - javax.servlet.jsp.jstl-api - 1.2.1 + javax.servlet + jstl + 1.2 @@ -100,7 +100,7 @@ 2.0.1.Final - org.hibernate + org.hibernate.validator hibernate-validator 6.0.7.Final @@ -168,28 +168,6 @@ - - - Spring snapshot - Spring Maven Snapshot Repository - http://repo.spring.io/snapshot - - false - - - true - - - - Spring milestone - Spring Maven Milestone Repository - http://repo.spring.io/milestone - - false - - - - ${project.artifactId} From 0dda6c19ddfbf1e27d7ff1a05478e59cd2bb02b7 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 23 Jan 2018 13:02:12 -0500 Subject: [PATCH 21/31] Remove tomcat maven plugin Unfortunately there is no current verison for Tomcat 8. --- README.md | 5 ----- pom.xml | 5 ----- 2 files changed, 10 deletions(-) diff --git a/README.md b/README.md index 90f383f0b..258cadc5a 100644 --- a/README.md +++ b/README.md @@ -30,11 +30,6 @@ To run the application: ------------------- From the command line with Maven: - $ cd spring-mvc-showcase - $ mvn tomcat7:run [-Dmaven.tomcat.port=] (In case 8080 is busy] - -or - $ cd spring-mvc-showcase $ mvn jetty:run diff --git a/pom.xml b/pom.xml index b0ffff80a..d2aee0c0c 100644 --- a/pom.xml +++ b/pom.xml @@ -239,11 +239,6 @@ ${java-version} - - org.apache.tomcat.maven - tomcat7-maven-plugin - 2.2 - org.eclipse.jetty jetty-maven-plugin From 0a979d145683b62eff62796acbc21ac8766088a0 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 23 Jan 2018 15:15:48 -0500 Subject: [PATCH 22/31] Replace XML with Java configuration --- pom.xml | 7 ++ .../mvc/config/MvcShowcaseAppInitializer.java | 34 ++++++++ .../samples/mvc/config/RootConfig.java | 31 +++++++ .../samples/mvc/config/WebMvcConfig.java | 80 +++++++++++++++++++ .../WEB-INF/spring/appServlet/controllers.xml | 15 ---- .../spring/appServlet/servlet-context.xml | 49 ------------ .../webapp/WEB-INF/spring/root-context.xml | 23 ------ src/main/webapp/WEB-INF/web.xml | 49 ------------ .../mvc/AbstractContextControllerTests.java | 3 +- 9 files changed, 154 insertions(+), 137 deletions(-) create mode 100644 src/main/java/org/springframework/samples/mvc/config/MvcShowcaseAppInitializer.java create mode 100644 src/main/java/org/springframework/samples/mvc/config/RootConfig.java create mode 100644 src/main/java/org/springframework/samples/mvc/config/WebMvcConfig.java delete mode 100644 src/main/webapp/WEB-INF/spring/appServlet/controllers.xml delete mode 100644 src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml delete mode 100644 src/main/webapp/WEB-INF/spring/root-context.xml delete mode 100644 src/main/webapp/WEB-INF/web.xml diff --git a/pom.xml b/pom.xml index d2aee0c0c..ccd8ca5ce 100644 --- a/pom.xml +++ b/pom.xml @@ -180,6 +180,13 @@ ${java-version} + + org.apache.maven.plugins + maven-war-plugin + + false + + org.apache.maven.plugins maven-surefire-plugin diff --git a/src/main/java/org/springframework/samples/mvc/config/MvcShowcaseAppInitializer.java b/src/main/java/org/springframework/samples/mvc/config/MvcShowcaseAppInitializer.java new file mode 100644 index 000000000..f0c83853b --- /dev/null +++ b/src/main/java/org/springframework/samples/mvc/config/MvcShowcaseAppInitializer.java @@ -0,0 +1,34 @@ +package org.springframework.samples.mvc.config; + +import javax.servlet.Filter; + +import org.springframework.web.filter.DelegatingFilterProxy; +import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; + +/** + * Initialize the Servlet container. This class is detected by the Servlet + * container on startup. + */ +public class MvcShowcaseAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer{ + + @Override + protected Class[] getRootConfigClasses() { + return new Class[] { RootConfig.class }; + } + + @Override + protected Class[] getServletConfigClasses() { + return new Class[] { WebMvcConfig.class }; + } + + @Override + protected String[] getServletMappings() { + return new String[] { "/" }; + } + + @Override + protected Filter[] getServletFilters() { + return new Filter[] { new DelegatingFilterProxy("csrfFilter") }; + } + +} diff --git a/src/main/java/org/springframework/samples/mvc/config/RootConfig.java b/src/main/java/org/springframework/samples/mvc/config/RootConfig.java new file mode 100644 index 000000000..b145f9031 --- /dev/null +++ b/src/main/java/org/springframework/samples/mvc/config/RootConfig.java @@ -0,0 +1,31 @@ +package org.springframework.samples.mvc.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.web.csrf.CsrfFilter; +import org.springframework.security.web.csrf.HttpSessionCsrfTokenRepository; +import org.springframework.security.web.servlet.support.csrf.CsrfRequestDataValueProcessor; +import org.springframework.web.servlet.support.RequestDataValueProcessor; + +// Root Context: defines shared resources visible to all other web components + +@Configuration +public class RootConfig { + + // CSRF protection. Here we only include the CsrfFilter instead of all of Spring Security. + // See http://docs.spring.io/spring-security/site/docs/current/reference/htmlsingle/#csrf + // for more information on Spring Security's CSRF protection + + @Bean + public CsrfFilter csrfFilter() { + return new CsrfFilter(new HttpSessionCsrfTokenRepository()); + } + + // Provides automatic CSRF token inclusion when using Spring MVC Form tags or Thymeleaf. + // See http://localhost:8080/#forms and form.jsp for examples + + @Bean + public RequestDataValueProcessor requestDataValueProcessor() { + return new CsrfRequestDataValueProcessor(); + } +} diff --git a/src/main/java/org/springframework/samples/mvc/config/WebMvcConfig.java b/src/main/java/org/springframework/samples/mvc/config/WebMvcConfig.java new file mode 100644 index 000000000..b73729309 --- /dev/null +++ b/src/main/java/org/springframework/samples/mvc/config/WebMvcConfig.java @@ -0,0 +1,80 @@ +package org.springframework.samples.mvc.config; + +import java.util.List; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.format.FormatterRegistry; +import org.springframework.samples.mvc.async.TimeoutCallableProcessingInterceptor; +import org.springframework.samples.mvc.convert.MaskFormatAnnotationFormatterFactory; +import org.springframework.samples.mvc.data.custom.CustomArgumentResolver; +import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.web.method.support.HandlerMethodArgumentResolver; +import org.springframework.web.multipart.MultipartResolver; +import org.springframework.web.multipart.commons.CommonsMultipartResolver; +import org.springframework.web.servlet.config.annotation.AsyncSupportConfigurer; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.PathMatchConfigurer; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; +import org.springframework.web.servlet.config.annotation.ViewResolverRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import org.springframework.web.util.UrlPathHelper; + +// DispatcherServlet context: defines Spring MVC infrastructure +// and web application components + +@Configuration +@ComponentScan(basePackages = "org.springframework.samples.mvc") +@EnableWebMvc +@EnableScheduling +public class WebMvcConfig implements WebMvcConfigurer { + + @Override + public void addFormatters(FormatterRegistry registry) { + registry.addFormatterForFieldAnnotation(new MaskFormatAnnotationFormatterFactory()); + } + + @Override + public void addArgumentResolvers(List resolvers) { + resolvers.add(new CustomArgumentResolver()); + } + + // Handle HTTP GET requests for /resources/** by efficiently serving + // static resources under ${webappRoot}/resources/ + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + registry.addResourceHandler("/resources/**").addResourceLocations("/resources/"); + } + + @Override + public void addViewControllers(ViewControllerRegistry registry) { + registry.addViewController("/").setViewName("home"); + } + + @Override + public void configureViewResolvers(ViewResolverRegistry registry) { + registry.jsp("/WEB-INF/views/", ".jsp"); + } + + @Override + public void configurePathMatch(PathMatchConfigurer configurer) { + UrlPathHelper pathHelper = new UrlPathHelper(); + pathHelper.setRemoveSemicolonContent(false); // For @MatrixVariable's + configurer.setUrlPathHelper(pathHelper); + } + + @Override + public void configureAsyncSupport(AsyncSupportConfigurer configurer) { + configurer.setDefaultTimeout(3000); + configurer.registerCallableInterceptors(new TimeoutCallableProcessingInterceptor()); + } + + @Bean + public MultipartResolver multipartResolver() { + return new CommonsMultipartResolver(); + } + +} diff --git a/src/main/webapp/WEB-INF/spring/appServlet/controllers.xml b/src/main/webapp/WEB-INF/spring/appServlet/controllers.xml deleted file mode 100644 index 56dba6e8c..000000000 --- a/src/main/webapp/WEB-INF/spring/appServlet/controllers.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml b/src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml deleted file mode 100644 index eb46e018b..000000000 --- a/src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/webapp/WEB-INF/spring/root-context.xml b/src/main/webapp/WEB-INF/spring/root-context.xml deleted file mode 100644 index 2c734abb4..000000000 --- a/src/main/webapp/WEB-INF/spring/root-context.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index d30ed1778..000000000 --- a/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - contextConfigLocation - /WEB-INF/spring/root-context.xml - - - - - org.springframework.web.context.ContextLoaderListener - - - - csrfFilter - org.springframework.web.filter.DelegatingFilterProxy - true - - - csrfFilter - /* - - - - - appServlet - org.springframework.web.servlet.DispatcherServlet - - contextConfigLocation - /WEB-INF/spring/appServlet/servlet-context.xml - - 1 - true - - - - appServlet - / - - - - - - - - \ No newline at end of file diff --git a/src/test/java/org/springframework/samples/mvc/AbstractContextControllerTests.java b/src/test/java/org/springframework/samples/mvc/AbstractContextControllerTests.java index c2116dac8..d687e8e99 100644 --- a/src/test/java/org/springframework/samples/mvc/AbstractContextControllerTests.java +++ b/src/test/java/org/springframework/samples/mvc/AbstractContextControllerTests.java @@ -1,12 +1,13 @@ package org.springframework.samples.mvc; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.samples.mvc.config.WebMvcConfig; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.web.context.WebApplicationContext; @WebAppConfiguration -@ContextConfiguration("file:src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml") +@ContextConfiguration(classes = WebMvcConfig.class) public class AbstractContextControllerTests { @Autowired From 17ff9a867f5eb56fcf8b4384bcd4c2fbcd1380a3 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Mon, 19 Mar 2018 14:43:32 -0400 Subject: [PATCH 23/31] Use shortcut mapping annotations --- .../samples/mvc/async/CallableController.java | 9 ++++--- .../mvc/async/DeferredResultController.java | 9 ++++--- .../mvc/convert/ConvertController.java | 15 ++++++----- .../mvc/data/RequestDataController.java | 25 ++++++++--------- .../data/custom/CustomArgumentController.java | 5 ++-- .../standard/StandardArgumentsController.java | 19 +++++++------ .../mvc/exceptions/ExceptionController.java | 6 ++--- .../mvc/fileupload/FileUploadController.java | 9 +++---- .../samples/mvc/form/FormController.java | 7 ++--- .../mapping/ClasslevelMappingController.java | 21 ++++++++------- .../mvc/mapping/MappingController.java | 24 ++++++++--------- .../MessageConvertersController.java | 27 ++++++++++--------- .../mvc/redirect/RedirectController.java | 9 ++++--- .../mvc/response/ResponseController.java | 11 ++++---- .../samples/mvc/simple/SimpleController.java | 4 +-- .../mvc/simple/SimpleControllerRevisited.java | 5 ++-- .../mvc/validation/ValidationController.java | 7 +++-- .../samples/mvc/views/ViewsController.java | 10 +++---- 18 files changed, 113 insertions(+), 109 deletions(-) diff --git a/src/main/java/org/springframework/samples/mvc/async/CallableController.java b/src/main/java/org/springframework/samples/mvc/async/CallableController.java index 345e0d49d..0fa649434 100644 --- a/src/main/java/org/springframework/samples/mvc/async/CallableController.java +++ b/src/main/java/org/springframework/samples/mvc/async/CallableController.java @@ -5,6 +5,7 @@ import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; @@ -15,7 +16,7 @@ public class CallableController { - @RequestMapping("/response-body") + @GetMapping("/response-body") public @ResponseBody Callable callable() { return new Callable() { @@ -27,7 +28,7 @@ public String call() throws Exception { }; } - @RequestMapping("/view") + @GetMapping("/view") public Callable callableWithView(final Model model) { return () -> { Thread.sleep(2000); @@ -37,7 +38,7 @@ public Callable callableWithView(final Model model) { }; } - @RequestMapping("/exception") + @GetMapping("/exception") public @ResponseBody Callable callableWithException( final @RequestParam(required=false, defaultValue="true") boolean handled) { @@ -53,7 +54,7 @@ public Callable callableWithView(final Model model) { }; } - @RequestMapping("/custom-timeout-handling") + @GetMapping("/custom-timeout-handling") public @ResponseBody WebAsyncTask callableWithCustomTimeoutHandling() { Callable callable = () -> { Thread.sleep(2000); diff --git a/src/main/java/org/springframework/samples/mvc/async/DeferredResultController.java b/src/main/java/org/springframework/samples/mvc/async/DeferredResultController.java index 3fe83f87c..41edfe72b 100644 --- a/src/main/java/org/springframework/samples/mvc/async/DeferredResultController.java +++ b/src/main/java/org/springframework/samples/mvc/async/DeferredResultController.java @@ -6,6 +6,7 @@ import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.context.request.async.DeferredResult; @@ -22,28 +23,28 @@ public class DeferredResultController { private final Queue> exceptionQueue = new ConcurrentLinkedQueue<>(); - @RequestMapping("/deferred-result/response-body") + @GetMapping("/deferred-result/response-body") public @ResponseBody DeferredResult deferredResult() { DeferredResult result = new DeferredResult<>(); this.responseBodyQueue.add(result); return result; } - @RequestMapping("/deferred-result/model-and-view") + @GetMapping("/deferred-result/model-and-view") public DeferredResult deferredResultWithView() { DeferredResult result = new DeferredResult<>(); this.mavQueue.add(result); return result; } - @RequestMapping("/deferred-result/exception") + @GetMapping("/deferred-result/exception") public @ResponseBody DeferredResult deferredResultWithException() { DeferredResult result = new DeferredResult<>(); this.exceptionQueue.add(result); return result; } - @RequestMapping("/deferred-result/timeout-value") + @GetMapping("/deferred-result/timeout-value") public @ResponseBody DeferredResult deferredResultWithTimeoutValue() { // Provide a default result in case of timeout and override the timeout value diff --git a/src/main/java/org/springframework/samples/mvc/convert/ConvertController.java b/src/main/java/org/springframework/samples/mvc/convert/ConvertController.java index 2db688250..6b552fd90 100644 --- a/src/main/java/org/springframework/samples/mvc/convert/ConvertController.java +++ b/src/main/java/org/springframework/samples/mvc/convert/ConvertController.java @@ -6,6 +6,7 @@ import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat.ISO; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; @@ -15,38 +16,38 @@ @RequestMapping("/convert") public class ConvertController { - @RequestMapping("primitive") + @GetMapping("primitive") public @ResponseBody String primitive(@RequestParam Integer value) { return "Converted primitive " + value; } // requires Joda-Time on the classpath - @RequestMapping("date/{value}") + @GetMapping("date/{value}") public @ResponseBody String date(@PathVariable @DateTimeFormat(iso=ISO.DATE) Date value) { return "Converted date " + value; } - @RequestMapping("collection") + @GetMapping("collection") public @ResponseBody String collection(@RequestParam Collection values) { return "Converted collection " + values; } - @RequestMapping("formattedCollection") + @GetMapping("formattedCollection") public @ResponseBody String formattedCollection(@RequestParam @DateTimeFormat(iso=ISO.DATE) Collection values) { return "Converted formatted collection " + values; } - @RequestMapping("bean") + @GetMapping("bean") public @ResponseBody String bean(JavaBean bean) { return "Converted " + bean; } - @RequestMapping("value") + @GetMapping("value") public @ResponseBody String valueObject(@RequestParam SocialSecurityNumber value) { return "Converted value object " + value; } - @RequestMapping("custom") + @GetMapping("custom") public @ResponseBody String customConverter(@RequestParam @MaskFormat("###-##-####") String value) { return "Converted '" + value + "' with a custom converter"; } diff --git a/src/main/java/org/springframework/samples/mvc/data/RequestDataController.java b/src/main/java/org/springframework/samples/mvc/data/RequestDataController.java index 5919e7cf9..f738efef2 100644 --- a/src/main/java/org/springframework/samples/mvc/data/RequestDataController.java +++ b/src/main/java/org/springframework/samples/mvc/data/RequestDataController.java @@ -3,12 +3,13 @@ import org.springframework.http.HttpEntity; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.CookieValue; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.MatrixVariable; import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; @@ -16,51 +17,51 @@ @RequestMapping("/data") public class RequestDataController { - @RequestMapping(value="param", method=RequestMethod.GET) + @GetMapping("param") public @ResponseBody String withParam(@RequestParam String foo) { return "Obtained 'foo' query parameter value '" + foo + "'"; } - @RequestMapping(value="group", method=RequestMethod.GET) + @GetMapping("group") public @ResponseBody String withParamGroup(JavaBean bean) { return "Obtained parameter group " + bean; } - @RequestMapping(value="path/{var}", method=RequestMethod.GET) + @GetMapping("path/{var}") public @ResponseBody String withPathVariable(@PathVariable String var) { return "Obtained 'var' path variable value '" + var + "'"; } - @RequestMapping(value="{path}/simple", method=RequestMethod.GET) + @GetMapping("{path}/simple") public @ResponseBody String withMatrixVariable(@PathVariable String path, @MatrixVariable String foo) { return "Obtained matrix variable 'foo=" + foo + "' from path segment '" + path + "'"; } - @RequestMapping(value="{path1}/{path2}", method=RequestMethod.GET) + @GetMapping("{path1}/{path2}") public @ResponseBody String withMatrixVariablesMultiple ( - @PathVariable String path1, @MatrixVariable(value="foo", pathVar="path1") String foo1, - @PathVariable String path2, @MatrixVariable(value="foo", pathVar="path2") String foo2) { + @PathVariable String path1, @MatrixVariable(name="foo", pathVar="path1") String foo1, + @PathVariable String path2, @MatrixVariable(name="foo", pathVar="path2") String foo2) { return "Obtained matrix variable foo=" + foo1 + " from path segment '" + path1 + "' and variable 'foo=" + foo2 + " from path segment '" + path2 + "'"; } - @RequestMapping(value="header", method=RequestMethod.GET) + @GetMapping("header") public @ResponseBody String withHeader(@RequestHeader String Accept) { return "Obtained 'Accept' header '" + Accept + "'"; } - @RequestMapping(value="cookie", method=RequestMethod.GET) + @GetMapping("cookie") public @ResponseBody String withCookie(@CookieValue String openid_provider) { return "Obtained 'openid_provider' cookie '" + openid_provider + "'"; } - @RequestMapping(value="body", method=RequestMethod.POST) + @PostMapping("body") public @ResponseBody String withBody(@RequestBody String body) { return "Posted request body '" + body + "'"; } - @RequestMapping(value="entity", method=RequestMethod.POST) + @PostMapping("entity") public @ResponseBody String withEntity(HttpEntity entity) { return "Posted request body '" + entity.getBody() + "'; headers = " + entity.getHeaders(); } diff --git a/src/main/java/org/springframework/samples/mvc/data/custom/CustomArgumentController.java b/src/main/java/org/springframework/samples/mvc/data/custom/CustomArgumentController.java index 3f3d4748b..2642faad5 100644 --- a/src/main/java/org/springframework/samples/mvc/data/custom/CustomArgumentController.java +++ b/src/main/java/org/springframework/samples/mvc/data/custom/CustomArgumentController.java @@ -3,9 +3,8 @@ import javax.servlet.http.HttpServletRequest; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; @Controller @@ -16,7 +15,7 @@ void beforeInvokingHandlerMethod(HttpServletRequest request) { request.setAttribute("foo", "bar"); } - @RequestMapping(value="/data/custom", method=RequestMethod.GET) + @GetMapping("/data/custom") public @ResponseBody String custom(@RequestAttribute("foo") String foo) { return "Got 'foo' request attribute value '" + foo + "'"; } diff --git a/src/main/java/org/springframework/samples/mvc/data/standard/StandardArgumentsController.java b/src/main/java/org/springframework/samples/mvc/data/standard/StandardArgumentsController.java index 4059b7f10..003d2c351 100644 --- a/src/main/java/org/springframework/samples/mvc/data/standard/StandardArgumentsController.java +++ b/src/main/java/org/springframework/samples/mvc/data/standard/StandardArgumentsController.java @@ -7,15 +7,14 @@ import java.io.Writer; import java.security.Principal; import java.util.Locale; - import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.springframework.stereotype.Controller; import org.springframework.util.FileCopyUtils; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.ResponseBody; @Controller @@ -23,7 +22,7 @@ public class StandardArgumentsController { // request related - @RequestMapping(value="/data/standard/request", method=RequestMethod.GET) + @GetMapping("/data/standard/request") public @ResponseBody String standardRequestArgs(HttpServletRequest request, Principal user, Locale locale) { StringBuilder buffer = new StringBuilder(); buffer.append("request = ").append(request).append(", "); @@ -32,36 +31,36 @@ public class StandardArgumentsController { return buffer.toString(); } - @RequestMapping(value="/data/standard/request/reader", method=RequestMethod.POST) + @PostMapping("/data/standard/request/reader") public @ResponseBody String requestReader(Reader requestBodyReader) throws IOException { return "Read char request body = " + FileCopyUtils.copyToString(requestBodyReader); } - @RequestMapping(value="/data/standard/request/is", method=RequestMethod.POST) + @PostMapping("/data/standard/request/is") public @ResponseBody String requestReader(InputStream requestBodyIs) throws IOException { return "Read binary request body = " + new String(FileCopyUtils.copyToByteArray(requestBodyIs)); } // response related - @RequestMapping("/data/standard/response") + @GetMapping("/data/standard/response") public @ResponseBody String response(HttpServletResponse response) { return "response = " + response; } - @RequestMapping("/data/standard/response/writer") + @GetMapping("/data/standard/response/writer") public void availableStandardResponseArguments(Writer responseWriter) throws IOException { responseWriter.write("Wrote char response using Writer"); } - @RequestMapping("/data/standard/response/os") + @GetMapping("/data/standard/response/os") public void availableStandardResponseArguments(OutputStream os) throws IOException { os.write("Wrote binary response using OutputStream".getBytes()); } // HttpSession - @RequestMapping("/data/standard/session") + @GetMapping("/data/standard/session") public @ResponseBody String session(HttpSession session) { StringBuilder buffer = new StringBuilder(); buffer.append("session=").append(session); diff --git a/src/main/java/org/springframework/samples/mvc/exceptions/ExceptionController.java b/src/main/java/org/springframework/samples/mvc/exceptions/ExceptionController.java index 8db32b5b0..f7f63eb75 100644 --- a/src/main/java/org/springframework/samples/mvc/exceptions/ExceptionController.java +++ b/src/main/java/org/springframework/samples/mvc/exceptions/ExceptionController.java @@ -2,18 +2,18 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ResponseBody; @Controller public class ExceptionController { - @RequestMapping("/exception") + @GetMapping("/exception") public @ResponseBody String exception() { throw new IllegalStateException("Sorry!"); } - @RequestMapping("/global-exception") + @GetMapping("/global-exception") public @ResponseBody String businessException() throws BusinessException { throw new BusinessException(); } diff --git a/src/main/java/org/springframework/samples/mvc/fileupload/FileUploadController.java b/src/main/java/org/springframework/samples/mvc/fileupload/FileUploadController.java index 4624a4878..b49489a3c 100644 --- a/src/main/java/org/springframework/samples/mvc/fileupload/FileUploadController.java +++ b/src/main/java/org/springframework/samples/mvc/fileupload/FileUploadController.java @@ -1,13 +1,12 @@ package org.springframework.samples.mvc.fileupload; -import java.io.IOException; - import org.springframework.mvc.extensions.ajax.AjaxUtils; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.context.request.WebRequest; import org.springframework.web.multipart.MultipartFile; @@ -21,11 +20,11 @@ public void ajaxAttribute(WebRequest request, Model model) { model.addAttribute("ajaxRequest", AjaxUtils.isAjaxRequest(request)); } - @RequestMapping(method=RequestMethod.GET) + @GetMapping public void fileUploadForm() { } - @RequestMapping(method=RequestMethod.POST) + @PostMapping public void processUpload(@RequestParam MultipartFile file, Model model) { model.addAttribute("message", "File '" + file.getOriginalFilename() + "' uploaded successfully"); } diff --git a/src/main/java/org/springframework/samples/mvc/form/FormController.java b/src/main/java/org/springframework/samples/mvc/form/FormController.java index a5b396976..b5837b9fe 100644 --- a/src/main/java/org/springframework/samples/mvc/form/FormController.java +++ b/src/main/java/org/springframework/samples/mvc/form/FormController.java @@ -6,9 +6,10 @@ import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.SessionAttributes; import org.springframework.web.context.request.WebRequest; import org.springframework.web.servlet.mvc.support.RedirectAttributes; @@ -33,11 +34,11 @@ public FormBean createFormBean() { return new FormBean(); } - @RequestMapping(method=RequestMethod.GET) + @GetMapping public void form() { } - @RequestMapping(method=RequestMethod.POST) + @PostMapping public String processSubmit(@Valid FormBean formBean, BindingResult result, @ModelAttribute("ajaxRequest") boolean ajaxRequest, Model model, RedirectAttributes redirectAttrs) { diff --git a/src/main/java/org/springframework/samples/mvc/mapping/ClasslevelMappingController.java b/src/main/java/org/springframework/samples/mvc/mapping/ClasslevelMappingController.java index d131a9cf4..7f5f8322f 100644 --- a/src/main/java/org/springframework/samples/mvc/mapping/ClasslevelMappingController.java +++ b/src/main/java/org/springframework/samples/mvc/mapping/ClasslevelMappingController.java @@ -3,57 +3,58 @@ import javax.servlet.http.HttpServletRequest; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; @Controller @RequestMapping("/class-mapping/*") public class ClasslevelMappingController { - @RequestMapping("/path") + @GetMapping("/path") public @ResponseBody String byPath() { return "Mapped by path!"; } - @RequestMapping(value="/path/*", method=RequestMethod.GET) + @GetMapping("/path/*") public @ResponseBody String byPathPattern(HttpServletRequest request) { return "Mapped by path pattern ('" + request.getRequestURI() + "')"; } - @RequestMapping(value="/method", method=RequestMethod.GET) + @GetMapping("/method") public @ResponseBody String byMethod() { return "Mapped by path + method"; } - @RequestMapping(value="/parameter", method=RequestMethod.GET, params="foo") + @GetMapping(path="/parameter", params="foo") public @ResponseBody String byParameter() { return "Mapped by path + method + presence of query parameter!"; } - @RequestMapping(value="/parameter", method=RequestMethod.GET, params="!foo") + @GetMapping(path="/parameter", params="!foo") public @ResponseBody String byParameterNegation() { return "Mapped by path + method + not presence of query!"; } - @RequestMapping(value="/header", method=RequestMethod.GET, headers="FooHeader=foo") + @GetMapping(path="/header", headers="FooHeader=foo") public @ResponseBody String byHeader() { return "Mapped by path + method + presence of header!"; } - @RequestMapping(value="/notheader", method=RequestMethod.GET, headers="!FooHeader") + @GetMapping(path="/notheader", headers="!FooHeader") public @ResponseBody String byHeaderNegation() { return "Mapped by path + method + absence of header!"; } - @RequestMapping(value="/consumes", method=RequestMethod.POST, consumes="application/json") + @PostMapping(path="/consumes", consumes="application/json") public @ResponseBody String byConsumes(@RequestBody JavaBean javaBean) { return "Mapped by path + method + consumable media type (javaBean '" + javaBean + "')"; } - @RequestMapping(value="/produces", method=RequestMethod.GET, produces="application/json") + @GetMapping(path="/produces", produces="application/json") public @ResponseBody JavaBean byProduces() { return new JavaBean(); } diff --git a/src/main/java/org/springframework/samples/mvc/mapping/MappingController.java b/src/main/java/org/springframework/samples/mvc/mapping/MappingController.java index cbebdcbe2..69b467186 100644 --- a/src/main/java/org/springframework/samples/mvc/mapping/MappingController.java +++ b/src/main/java/org/springframework/samples/mvc/mapping/MappingController.java @@ -4,60 +4,60 @@ import org.springframework.http.MediaType; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; @Controller public class MappingController { - @RequestMapping("/mapping/path") + @GetMapping("/mapping/path") public @ResponseBody String byPath() { return "Mapped by path!"; } - @RequestMapping(value="/mapping/path/*", method=RequestMethod.GET) + @GetMapping("/mapping/path/*") public @ResponseBody String byPathPattern(HttpServletRequest request) { return "Mapped by path pattern ('" + request.getRequestURI() + "')"; } - @RequestMapping(value="/mapping/method", method=RequestMethod.GET) + @GetMapping("/mapping/method") public @ResponseBody String byMethod() { return "Mapped by path + method"; } - @RequestMapping(value="/mapping/parameter", method=RequestMethod.GET, params="foo") + @GetMapping(path="/mapping/parameter", params="foo") public @ResponseBody String byParameter() { return "Mapped by path + method + presence of query parameter!"; } - @RequestMapping(value="/mapping/parameter", method=RequestMethod.GET, params="!foo") + @GetMapping(path="/mapping/parameter", params="!foo") public @ResponseBody String byParameterNegation() { return "Mapped by path + method + not presence of query parameter!"; } - @RequestMapping(value="/mapping/header", method=RequestMethod.GET, headers="FooHeader=foo") + @GetMapping(path="/mapping/header", headers="FooHeader=foo") public @ResponseBody String byHeader() { return "Mapped by path + method + presence of header!"; } - @RequestMapping(value="/mapping/header", method=RequestMethod.GET, headers="!FooHeader") + @GetMapping(path="/mapping/header", headers="!FooHeader") public @ResponseBody String byHeaderNegation() { return "Mapped by path + method + absence of header!"; } - @RequestMapping(value="/mapping/consumes", method=RequestMethod.POST, consumes=MediaType.APPLICATION_JSON_VALUE) + @PostMapping(path="/mapping/consumes", consumes=MediaType.APPLICATION_JSON_VALUE) public @ResponseBody String byConsumes(@RequestBody JavaBean javaBean) { return "Mapped by path + method + consumable media type (javaBean '" + javaBean + "')"; } - @RequestMapping(value="/mapping/produces", method=RequestMethod.GET, produces=MediaType.APPLICATION_JSON_VALUE) + @GetMapping(path="/mapping/produces", produces=MediaType.APPLICATION_JSON_VALUE) public @ResponseBody JavaBean byProducesJson() { return new JavaBean(); } - @RequestMapping(value="/mapping/produces", method=RequestMethod.GET, produces=MediaType.APPLICATION_XML_VALUE) + @GetMapping(path="/mapping/produces", produces=MediaType.APPLICATION_XML_VALUE) public @ResponseBody JavaBean byProducesXml() { return new JavaBean(); } diff --git a/src/main/java/org/springframework/samples/mvc/messageconverters/MessageConvertersController.java b/src/main/java/org/springframework/samples/mvc/messageconverters/MessageConvertersController.java index 47da6ee95..921078068 100644 --- a/src/main/java/org/springframework/samples/mvc/messageconverters/MessageConvertersController.java +++ b/src/main/java/org/springframework/samples/mvc/messageconverters/MessageConvertersController.java @@ -8,10 +8,11 @@ import org.springframework.stereotype.Controller; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; @Controller @@ -20,24 +21,24 @@ public class MessageConvertersController { // StringHttpMessageConverter - @RequestMapping(value="/string", method=RequestMethod.POST) + @PostMapping("/string") public @ResponseBody String readString(@RequestBody String string) { return "Read string '" + string + "'"; } - @RequestMapping(value="/string", method=RequestMethod.GET) + @GetMapping("/string") public @ResponseBody String writeString() { return "Wrote a string"; } // Form encoded data (application/x-www-form-urlencoded) - @RequestMapping(value="/form", method=RequestMethod.POST) + @PostMapping("/form") public @ResponseBody String readForm(@ModelAttribute JavaBean bean) { return "Read x-www-form-urlencoded: " + bean; } - @RequestMapping(value="/form", method=RequestMethod.GET) + @GetMapping("/form") public @ResponseBody MultiValueMap writeForm() { MultiValueMap map = new LinkedMultiValueMap(); map.add("foo", "bar"); @@ -47,36 +48,36 @@ public class MessageConvertersController { // Jaxb2RootElementHttpMessageConverter (requires JAXB2 on the classpath - useful for serving clients that expect to work with XML) - @RequestMapping(value="/xml", method=RequestMethod.POST) + @PostMapping("/xml") public @ResponseBody String readXml(@RequestBody JavaBean bean) { return "Read from XML: " + bean; } - @RequestMapping(value="/xml", method=RequestMethod.GET) + @GetMapping("/xml") public @ResponseBody JavaBean writeXml() { return new JavaBean("bar", "apple"); } // MappingJacksonHttpMessageConverter (requires Jackson on the classpath - particularly useful for serving JavaScript clients that expect to work with JSON) - @RequestMapping(value="/json", method=RequestMethod.POST) + @PostMapping("/json") public @ResponseBody String readJson(@Valid @RequestBody JavaBean bean) { return "Read from JSON: " + bean; } - @RequestMapping(value="/json", method=RequestMethod.GET) + @GetMapping("/json") public @ResponseBody JavaBean writeJson() { return new JavaBean("bar", "apple"); } // AtomFeedHttpMessageConverter (requires Rome on the classpath - useful for serving Atom feeds) - @RequestMapping(value="/atom", method=RequestMethod.POST) + @PostMapping("/atom") public @ResponseBody String readFeed(@RequestBody Feed feed) { return "Read " + feed.getTitle(); } - @RequestMapping(value="/atom", method=RequestMethod.GET) + @GetMapping("/atom") public @ResponseBody Feed writeFeed() { Feed feed = new Feed(); feed.setFeedType("atom_1.0"); @@ -86,12 +87,12 @@ public class MessageConvertersController { // RssChannelHttpMessageConverter (requires Rome on the classpath - useful for serving RSS feeds) - @RequestMapping(value="/rss", method=RequestMethod.POST) + @PostMapping("/rss") public @ResponseBody String readChannel(@RequestBody Channel channel) { return "Read " + channel.getTitle(); } - @RequestMapping(value="/rss", method=RequestMethod.GET) + @GetMapping("/rss") public @ResponseBody Channel writeChannel() { Channel channel = new Channel(); channel.setFeedType("rss_2.0"); diff --git a/src/main/java/org/springframework/samples/mvc/redirect/RedirectController.java b/src/main/java/org/springframework/samples/mvc/redirect/RedirectController.java index c34470592..174b6b68e 100644 --- a/src/main/java/org/springframework/samples/mvc/redirect/RedirectController.java +++ b/src/main/java/org/springframework/samples/mvc/redirect/RedirectController.java @@ -3,11 +3,12 @@ import javax.inject.Inject; import org.joda.time.LocalDate; + import org.springframework.core.convert.ConversionService; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.servlet.mvc.support.RedirectAttributes; import org.springframework.web.util.UriComponents; @@ -24,14 +25,14 @@ public RedirectController(ConversionService conversionService) { this.conversionService = conversionService; } - @RequestMapping(value="/uriTemplate", method=RequestMethod.GET) + @GetMapping("/uriTemplate") public String uriTemplate(RedirectAttributes redirectAttrs) { redirectAttrs.addAttribute("account", "a123"); // Used as URI template variable redirectAttrs.addAttribute("date", new LocalDate(2011, 12, 31)); // Appended as a query parameter return "redirect:/redirect/{account}"; } - @RequestMapping(value="/uriComponentsBuilder", method=RequestMethod.GET) + @GetMapping("/uriComponentsBuilder") public String uriComponentsBuilder() { String date = this.conversionService.convert(new LocalDate(2011, 12, 31), String.class); UriComponents redirectUri = UriComponentsBuilder.fromPath("/redirect/{account}").queryParam("date", date) @@ -39,7 +40,7 @@ public String uriComponentsBuilder() { return "redirect:" + redirectUri.toUriString(); } - @RequestMapping(value="/{account}", method=RequestMethod.GET) + @GetMapping("/{account}") public String show(@PathVariable String account, @RequestParam(required=false) LocalDate date) { return "redirect/redirectResults"; } diff --git a/src/main/java/org/springframework/samples/mvc/response/ResponseController.java b/src/main/java/org/springframework/samples/mvc/response/ResponseController.java index 22e15ff83..8a36bcfda 100644 --- a/src/main/java/org/springframework/samples/mvc/response/ResponseController.java +++ b/src/main/java/org/springframework/samples/mvc/response/ResponseController.java @@ -5,6 +5,7 @@ import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; @@ -13,28 +14,28 @@ @RequestMapping(value="/response", method=RequestMethod.GET) public class ResponseController { - @RequestMapping("/annotation") + @GetMapping("/annotation") public @ResponseBody String responseBody() { return "The String ResponseBody"; } - @RequestMapping("/charset/accept") + @GetMapping("/charset/accept") public @ResponseBody String responseAcceptHeaderCharset() { return "\u3053\u3093\u306b\u3061\u306f\u4e16\u754c\uff01 (\"Hello world!\" in Japanese)"; } - @RequestMapping(value="/charset/produce", produces="text/plain;charset=UTF-8") + @GetMapping(value="/charset/produce", produces="text/plain;charset=UTF-8") public @ResponseBody String responseProducesConditionCharset() { return "\u3053\u3093\u306b\u3061\u306f\u4e16\u754c\uff01 (\"Hello world!\" in Japanese)"; } - @RequestMapping("/entity/status") + @GetMapping("/entity/status") public ResponseEntity responseEntityStatusCode() { return new ResponseEntity("The String ResponseBody with custom status code (403 Forbidden)", HttpStatus.FORBIDDEN); } - @RequestMapping("/entity/headers") + @GetMapping("/entity/headers") public ResponseEntity responseEntityCustomHeaders() { HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.TEXT_PLAIN); diff --git a/src/main/java/org/springframework/samples/mvc/simple/SimpleController.java b/src/main/java/org/springframework/samples/mvc/simple/SimpleController.java index eb37c30e5..fc3975152 100644 --- a/src/main/java/org/springframework/samples/mvc/simple/SimpleController.java +++ b/src/main/java/org/springframework/samples/mvc/simple/SimpleController.java @@ -1,13 +1,13 @@ package org.springframework.samples.mvc.simple; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ResponseBody; @Controller public class SimpleController { - @RequestMapping("/simple") + @GetMapping("/simple") public @ResponseBody String simple() { return "Hello world!"; } diff --git a/src/main/java/org/springframework/samples/mvc/simple/SimpleControllerRevisited.java b/src/main/java/org/springframework/samples/mvc/simple/SimpleControllerRevisited.java index 67efe40f9..3430388e8 100644 --- a/src/main/java/org/springframework/samples/mvc/simple/SimpleControllerRevisited.java +++ b/src/main/java/org/springframework/samples/mvc/simple/SimpleControllerRevisited.java @@ -1,14 +1,13 @@ package org.springframework.samples.mvc.simple; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ResponseBody; @Controller public class SimpleControllerRevisited { - @RequestMapping(value="/simple/revisited", method=RequestMethod.GET, headers="Accept=text/plain") + @GetMapping(path="/simple/revisited", headers="Accept=text/plain") public @ResponseBody String simple() { return "Hello world revisited!"; } diff --git a/src/main/java/org/springframework/samples/mvc/validation/ValidationController.java b/src/main/java/org/springframework/samples/mvc/validation/ValidationController.java index 6384e3065..edb1a882f 100644 --- a/src/main/java/org/springframework/samples/mvc/validation/ValidationController.java +++ b/src/main/java/org/springframework/samples/mvc/validation/ValidationController.java @@ -4,16 +4,15 @@ import org.springframework.stereotype.Controller; import org.springframework.validation.BindingResult; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.GetMapping; @Controller public class ValidationController { // enforcement of constraints on the JavaBean arg require a JSR-303 provider on the classpath - @RequestMapping("/validate") - public @ResponseBody String validate(@Valid JavaBean bean, BindingResult result) { + @GetMapping("/validate") + public String validate(@Valid JavaBean bean, BindingResult result) { if (result.hasErrors()) { return "Object has validation errors"; } else { diff --git a/src/main/java/org/springframework/samples/mvc/views/ViewsController.java b/src/main/java/org/springframework/samples/mvc/views/ViewsController.java index d8ce95f8e..b1f9ab1b2 100644 --- a/src/main/java/org/springframework/samples/mvc/views/ViewsController.java +++ b/src/main/java/org/springframework/samples/mvc/views/ViewsController.java @@ -4,35 +4,35 @@ import org.springframework.stereotype.Controller; import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; @Controller @RequestMapping("/views/*") public class ViewsController { - @RequestMapping(value="html", method=RequestMethod.GET) + @GetMapping("html") public String prepare(Model model) { model.addAttribute("foo", "bar"); model.addAttribute("fruit", "apple"); return "views/html"; } - @RequestMapping(value="/viewName", method=RequestMethod.GET) + @GetMapping("/viewName") public void usingRequestToViewNameTranslator(Model model) { model.addAttribute("foo", "bar"); model.addAttribute("fruit", "apple"); } - @RequestMapping(value="pathVariables/{foo}/{fruit}", method=RequestMethod.GET) + @GetMapping("pathVariables/{foo}/{fruit}") public String pathVars(@PathVariable String foo, @PathVariable String fruit) { // No need to add @PathVariables "foo" and "fruit" to the model // They will be merged in the model before rendering return "views/html"; } - @RequestMapping(value="dataBinding/{foo}/{fruit}", method=RequestMethod.GET) + @GetMapping("dataBinding/{foo}/{fruit}") public String dataBinding(@Valid JavaBean javaBean, Model model) { // JavaBean "foo" and "fruit" properties populated from URI variables return "views/dataBinding"; From 5c8de177eeb4e79cbd2efb34661d562fb21ae12e Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Mon, 19 Mar 2018 14:50:09 -0400 Subject: [PATCH 24/31] Use @RestController where feasible --- .../mvc/convert/ConvertController.java | 19 ++++++------- .../mvc/data/RequestDataController.java | 23 ++++++++------- .../data/custom/CustomArgumentController.java | 7 ++--- .../standard/StandardArgumentsController.java | 15 +++++----- .../mvc/exceptions/ExceptionController.java | 11 ++++---- .../exceptions/GlobalExceptionHandler.java | 7 ++--- .../mapping/ClasslevelMappingController.java | 23 ++++++++------- .../mvc/mapping/MappingController.java | 25 ++++++++--------- .../MessageConvertersController.java | 28 +++++++++---------- .../mvc/response/ResponseController.java | 11 ++++---- .../samples/mvc/simple/SimpleController.java | 7 ++--- .../mvc/simple/SimpleControllerRevisited.java | 7 ++--- .../mvc/validation/ValidationController.java | 3 +- 13 files changed, 88 insertions(+), 98 deletions(-) diff --git a/src/main/java/org/springframework/samples/mvc/convert/ConvertController.java b/src/main/java/org/springframework/samples/mvc/convert/ConvertController.java index 6b552fd90..09da254ab 100644 --- a/src/main/java/org/springframework/samples/mvc/convert/ConvertController.java +++ b/src/main/java/org/springframework/samples/mvc/convert/ConvertController.java @@ -5,50 +5,49 @@ import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat.ISO; -import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; -@Controller +@RestController @RequestMapping("/convert") public class ConvertController { @GetMapping("primitive") - public @ResponseBody String primitive(@RequestParam Integer value) { + public String primitive(@RequestParam Integer value) { return "Converted primitive " + value; } // requires Joda-Time on the classpath @GetMapping("date/{value}") - public @ResponseBody String date(@PathVariable @DateTimeFormat(iso=ISO.DATE) Date value) { + public String date(@PathVariable @DateTimeFormat(iso=ISO.DATE) Date value) { return "Converted date " + value; } @GetMapping("collection") - public @ResponseBody String collection(@RequestParam Collection values) { + public String collection(@RequestParam Collection values) { return "Converted collection " + values; } @GetMapping("formattedCollection") - public @ResponseBody String formattedCollection(@RequestParam @DateTimeFormat(iso=ISO.DATE) Collection values) { + public String formattedCollection(@RequestParam @DateTimeFormat(iso=ISO.DATE) Collection values) { return "Converted formatted collection " + values; } @GetMapping("bean") - public @ResponseBody String bean(JavaBean bean) { + public String bean(JavaBean bean) { return "Converted " + bean; } @GetMapping("value") - public @ResponseBody String valueObject(@RequestParam SocialSecurityNumber value) { + public String valueObject(@RequestParam SocialSecurityNumber value) { return "Converted value object " + value; } @GetMapping("custom") - public @ResponseBody String customConverter(@RequestParam @MaskFormat("###-##-####") String value) { + public String customConverter(@RequestParam @MaskFormat("###-##-####") String value) { return "Converted '" + value + "' with a custom converter"; } diff --git a/src/main/java/org/springframework/samples/mvc/data/RequestDataController.java b/src/main/java/org/springframework/samples/mvc/data/RequestDataController.java index f738efef2..9d0b7e99c 100644 --- a/src/main/java/org/springframework/samples/mvc/data/RequestDataController.java +++ b/src/main/java/org/springframework/samples/mvc/data/RequestDataController.java @@ -1,7 +1,6 @@ package org.springframework.samples.mvc.data; import org.springframework.http.HttpEntity; -import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.CookieValue; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.MatrixVariable; @@ -11,34 +10,34 @@ import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; -@Controller +@RestController @RequestMapping("/data") public class RequestDataController { @GetMapping("param") - public @ResponseBody String withParam(@RequestParam String foo) { + public String withParam(@RequestParam String foo) { return "Obtained 'foo' query parameter value '" + foo + "'"; } @GetMapping("group") - public @ResponseBody String withParamGroup(JavaBean bean) { + public String withParamGroup(JavaBean bean) { return "Obtained parameter group " + bean; } @GetMapping("path/{var}") - public @ResponseBody String withPathVariable(@PathVariable String var) { + public String withPathVariable(@PathVariable String var) { return "Obtained 'var' path variable value '" + var + "'"; } @GetMapping("{path}/simple") - public @ResponseBody String withMatrixVariable(@PathVariable String path, @MatrixVariable String foo) { + public String withMatrixVariable(@PathVariable String path, @MatrixVariable String foo) { return "Obtained matrix variable 'foo=" + foo + "' from path segment '" + path + "'"; } @GetMapping("{path1}/{path2}") - public @ResponseBody String withMatrixVariablesMultiple ( + public String withMatrixVariablesMultiple ( @PathVariable String path1, @MatrixVariable(name="foo", pathVar="path1") String foo1, @PathVariable String path2, @MatrixVariable(name="foo", pathVar="path2") String foo2) { @@ -47,22 +46,22 @@ public class RequestDataController { } @GetMapping("header") - public @ResponseBody String withHeader(@RequestHeader String Accept) { + public String withHeader(@RequestHeader String Accept) { return "Obtained 'Accept' header '" + Accept + "'"; } @GetMapping("cookie") - public @ResponseBody String withCookie(@CookieValue String openid_provider) { + public String withCookie(@CookieValue String openid_provider) { return "Obtained 'openid_provider' cookie '" + openid_provider + "'"; } @PostMapping("body") - public @ResponseBody String withBody(@RequestBody String body) { + public String withBody(@RequestBody String body) { return "Posted request body '" + body + "'"; } @PostMapping("entity") - public @ResponseBody String withEntity(HttpEntity entity) { + public String withEntity(HttpEntity entity) { return "Posted request body '" + entity.getBody() + "'; headers = " + entity.getHeaders(); } diff --git a/src/main/java/org/springframework/samples/mvc/data/custom/CustomArgumentController.java b/src/main/java/org/springframework/samples/mvc/data/custom/CustomArgumentController.java index 2642faad5..66368fa34 100644 --- a/src/main/java/org/springframework/samples/mvc/data/custom/CustomArgumentController.java +++ b/src/main/java/org/springframework/samples/mvc/data/custom/CustomArgumentController.java @@ -2,12 +2,11 @@ import javax.servlet.http.HttpServletRequest; -import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; -@Controller +@RestController public class CustomArgumentController { @ModelAttribute @@ -16,7 +15,7 @@ void beforeInvokingHandlerMethod(HttpServletRequest request) { } @GetMapping("/data/custom") - public @ResponseBody String custom(@RequestAttribute("foo") String foo) { + public String custom(@RequestAttribute("foo") String foo) { return "Got 'foo' request attribute value '" + foo + "'"; } diff --git a/src/main/java/org/springframework/samples/mvc/data/standard/StandardArgumentsController.java b/src/main/java/org/springframework/samples/mvc/data/standard/StandardArgumentsController.java index 003d2c351..c5276ae91 100644 --- a/src/main/java/org/springframework/samples/mvc/data/standard/StandardArgumentsController.java +++ b/src/main/java/org/springframework/samples/mvc/data/standard/StandardArgumentsController.java @@ -11,19 +11,18 @@ import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; -import org.springframework.stereotype.Controller; import org.springframework.util.FileCopyUtils; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; -@Controller +@RestController public class StandardArgumentsController { // request related @GetMapping("/data/standard/request") - public @ResponseBody String standardRequestArgs(HttpServletRequest request, Principal user, Locale locale) { + public String standardRequestArgs(HttpServletRequest request, Principal user, Locale locale) { StringBuilder buffer = new StringBuilder(); buffer.append("request = ").append(request).append(", "); buffer.append("userPrincipal = ").append(user).append(", "); @@ -32,19 +31,19 @@ public class StandardArgumentsController { } @PostMapping("/data/standard/request/reader") - public @ResponseBody String requestReader(Reader requestBodyReader) throws IOException { + public String requestReader(Reader requestBodyReader) throws IOException { return "Read char request body = " + FileCopyUtils.copyToString(requestBodyReader); } @PostMapping("/data/standard/request/is") - public @ResponseBody String requestReader(InputStream requestBodyIs) throws IOException { + public String requestReader(InputStream requestBodyIs) throws IOException { return "Read binary request body = " + new String(FileCopyUtils.copyToByteArray(requestBodyIs)); } // response related @GetMapping("/data/standard/response") - public @ResponseBody String response(HttpServletResponse response) { + public String response(HttpServletResponse response) { return "response = " + response; } @@ -61,7 +60,7 @@ public void availableStandardResponseArguments(OutputStream os) throws IOExcepti // HttpSession @GetMapping("/data/standard/session") - public @ResponseBody String session(HttpSession session) { + public String session(HttpSession session) { StringBuilder buffer = new StringBuilder(); buffer.append("session=").append(session); return buffer.toString(); diff --git a/src/main/java/org/springframework/samples/mvc/exceptions/ExceptionController.java b/src/main/java/org/springframework/samples/mvc/exceptions/ExceptionController.java index f7f63eb75..7b3e0d616 100644 --- a/src/main/java/org/springframework/samples/mvc/exceptions/ExceptionController.java +++ b/src/main/java/org/springframework/samples/mvc/exceptions/ExceptionController.java @@ -1,25 +1,24 @@ package org.springframework.samples.mvc.exceptions; -import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; -@Controller +@RestController public class ExceptionController { @GetMapping("/exception") - public @ResponseBody String exception() { + public String exception() { throw new IllegalStateException("Sorry!"); } @GetMapping("/global-exception") - public @ResponseBody String businessException() throws BusinessException { + public String businessException() throws BusinessException { throw new BusinessException(); } @ExceptionHandler - public @ResponseBody String handle(IllegalStateException e) { + public String handle(IllegalStateException e) { return "IllegalStateException handled!"; } diff --git a/src/main/java/org/springframework/samples/mvc/exceptions/GlobalExceptionHandler.java b/src/main/java/org/springframework/samples/mvc/exceptions/GlobalExceptionHandler.java index f50339790..10d5da8ce 100644 --- a/src/main/java/org/springframework/samples/mvc/exceptions/GlobalExceptionHandler.java +++ b/src/main/java/org/springframework/samples/mvc/exceptions/GlobalExceptionHandler.java @@ -1,14 +1,13 @@ package org.springframework.samples.mvc.exceptions; -import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestControllerAdvice; -@ControllerAdvice +@RestControllerAdvice public class GlobalExceptionHandler { @ExceptionHandler - public @ResponseBody String handleBusinessException(BusinessException ex) { + public String handleBusinessException(BusinessException ex) { return "Handled BusinessException"; } diff --git a/src/main/java/org/springframework/samples/mvc/mapping/ClasslevelMappingController.java b/src/main/java/org/springframework/samples/mvc/mapping/ClasslevelMappingController.java index 7f5f8322f..dafa6d1a3 100644 --- a/src/main/java/org/springframework/samples/mvc/mapping/ClasslevelMappingController.java +++ b/src/main/java/org/springframework/samples/mvc/mapping/ClasslevelMappingController.java @@ -2,60 +2,59 @@ import javax.servlet.http.HttpServletRequest; -import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; -@Controller +@RestController @RequestMapping("/class-mapping/*") public class ClasslevelMappingController { @GetMapping("/path") - public @ResponseBody String byPath() { + public String byPath() { return "Mapped by path!"; } @GetMapping("/path/*") - public @ResponseBody String byPathPattern(HttpServletRequest request) { + public String byPathPattern(HttpServletRequest request) { return "Mapped by path pattern ('" + request.getRequestURI() + "')"; } @GetMapping("/method") - public @ResponseBody String byMethod() { + public String byMethod() { return "Mapped by path + method"; } @GetMapping(path="/parameter", params="foo") - public @ResponseBody String byParameter() { + public String byParameter() { return "Mapped by path + method + presence of query parameter!"; } @GetMapping(path="/parameter", params="!foo") - public @ResponseBody String byParameterNegation() { + public String byParameterNegation() { return "Mapped by path + method + not presence of query!"; } @GetMapping(path="/header", headers="FooHeader=foo") - public @ResponseBody String byHeader() { + public String byHeader() { return "Mapped by path + method + presence of header!"; } @GetMapping(path="/notheader", headers="!FooHeader") - public @ResponseBody String byHeaderNegation() { + public String byHeaderNegation() { return "Mapped by path + method + absence of header!"; } @PostMapping(path="/consumes", consumes="application/json") - public @ResponseBody String byConsumes(@RequestBody JavaBean javaBean) { + public String byConsumes(@RequestBody JavaBean javaBean) { return "Mapped by path + method + consumable media type (javaBean '" + javaBean + "')"; } @GetMapping(path="/produces", produces="application/json") - public @ResponseBody JavaBean byProduces() { + public JavaBean byProduces() { return new JavaBean(); } diff --git a/src/main/java/org/springframework/samples/mvc/mapping/MappingController.java b/src/main/java/org/springframework/samples/mvc/mapping/MappingController.java index 69b467186..823d9ad0b 100644 --- a/src/main/java/org/springframework/samples/mvc/mapping/MappingController.java +++ b/src/main/java/org/springframework/samples/mvc/mapping/MappingController.java @@ -3,62 +3,61 @@ import javax.servlet.http.HttpServletRequest; import org.springframework.http.MediaType; -import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; -@Controller +@RestController public class MappingController { @GetMapping("/mapping/path") - public @ResponseBody String byPath() { + public String byPath() { return "Mapped by path!"; } @GetMapping("/mapping/path/*") - public @ResponseBody String byPathPattern(HttpServletRequest request) { + public String byPathPattern(HttpServletRequest request) { return "Mapped by path pattern ('" + request.getRequestURI() + "')"; } @GetMapping("/mapping/method") - public @ResponseBody String byMethod() { + public String byMethod() { return "Mapped by path + method"; } @GetMapping(path="/mapping/parameter", params="foo") - public @ResponseBody String byParameter() { + public String byParameter() { return "Mapped by path + method + presence of query parameter!"; } @GetMapping(path="/mapping/parameter", params="!foo") - public @ResponseBody String byParameterNegation() { + public String byParameterNegation() { return "Mapped by path + method + not presence of query parameter!"; } @GetMapping(path="/mapping/header", headers="FooHeader=foo") - public @ResponseBody String byHeader() { + public String byHeader() { return "Mapped by path + method + presence of header!"; } @GetMapping(path="/mapping/header", headers="!FooHeader") - public @ResponseBody String byHeaderNegation() { + public String byHeaderNegation() { return "Mapped by path + method + absence of header!"; } @PostMapping(path="/mapping/consumes", consumes=MediaType.APPLICATION_JSON_VALUE) - public @ResponseBody String byConsumes(@RequestBody JavaBean javaBean) { + public String byConsumes(@RequestBody JavaBean javaBean) { return "Mapped by path + method + consumable media type (javaBean '" + javaBean + "')"; } @GetMapping(path="/mapping/produces", produces=MediaType.APPLICATION_JSON_VALUE) - public @ResponseBody JavaBean byProducesJson() { + public JavaBean byProducesJson() { return new JavaBean(); } @GetMapping(path="/mapping/produces", produces=MediaType.APPLICATION_XML_VALUE) - public @ResponseBody JavaBean byProducesXml() { + public JavaBean byProducesXml() { return new JavaBean(); } diff --git a/src/main/java/org/springframework/samples/mvc/messageconverters/MessageConvertersController.java b/src/main/java/org/springframework/samples/mvc/messageconverters/MessageConvertersController.java index 921078068..780e67df5 100644 --- a/src/main/java/org/springframework/samples/mvc/messageconverters/MessageConvertersController.java +++ b/src/main/java/org/springframework/samples/mvc/messageconverters/MessageConvertersController.java @@ -5,7 +5,6 @@ import com.rometools.rome.feed.atom.Feed; import com.rometools.rome.feed.rss.Channel; -import org.springframework.stereotype.Controller; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.web.bind.annotation.GetMapping; @@ -14,32 +13,33 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; -@Controller +@RestController @RequestMapping("/messageconverters") public class MessageConvertersController { // StringHttpMessageConverter @PostMapping("/string") - public @ResponseBody String readString(@RequestBody String string) { + public String readString(@RequestBody String string) { return "Read string '" + string + "'"; } @GetMapping("/string") - public @ResponseBody String writeString() { + public String writeString() { return "Wrote a string"; } // Form encoded data (application/x-www-form-urlencoded) @PostMapping("/form") - public @ResponseBody String readForm(@ModelAttribute JavaBean bean) { + public String readForm(@ModelAttribute JavaBean bean) { return "Read x-www-form-urlencoded: " + bean; } @GetMapping("/form") - public @ResponseBody MultiValueMap writeForm() { + public MultiValueMap writeForm() { MultiValueMap map = new LinkedMultiValueMap(); map.add("foo", "bar"); map.add("fruit", "apple"); @@ -49,36 +49,36 @@ public class MessageConvertersController { // Jaxb2RootElementHttpMessageConverter (requires JAXB2 on the classpath - useful for serving clients that expect to work with XML) @PostMapping("/xml") - public @ResponseBody String readXml(@RequestBody JavaBean bean) { + public String readXml(@RequestBody JavaBean bean) { return "Read from XML: " + bean; } @GetMapping("/xml") - public @ResponseBody JavaBean writeXml() { + public JavaBean writeXml() { return new JavaBean("bar", "apple"); } // MappingJacksonHttpMessageConverter (requires Jackson on the classpath - particularly useful for serving JavaScript clients that expect to work with JSON) @PostMapping("/json") - public @ResponseBody String readJson(@Valid @RequestBody JavaBean bean) { + public String readJson(@Valid @RequestBody JavaBean bean) { return "Read from JSON: " + bean; } @GetMapping("/json") - public @ResponseBody JavaBean writeJson() { + public JavaBean writeJson() { return new JavaBean("bar", "apple"); } // AtomFeedHttpMessageConverter (requires Rome on the classpath - useful for serving Atom feeds) @PostMapping("/atom") - public @ResponseBody String readFeed(@RequestBody Feed feed) { + public String readFeed(@RequestBody Feed feed) { return "Read " + feed.getTitle(); } @GetMapping("/atom") - public @ResponseBody Feed writeFeed() { + public Feed writeFeed() { Feed feed = new Feed(); feed.setFeedType("atom_1.0"); feed.setTitle("My Atom feed"); @@ -88,12 +88,12 @@ public class MessageConvertersController { // RssChannelHttpMessageConverter (requires Rome on the classpath - useful for serving RSS feeds) @PostMapping("/rss") - public @ResponseBody String readChannel(@RequestBody Channel channel) { + public String readChannel(@RequestBody Channel channel) { return "Read " + channel.getTitle(); } @GetMapping("/rss") - public @ResponseBody Channel writeChannel() { + public Channel writeChannel() { Channel channel = new Channel(); channel.setFeedType("rss_2.0"); channel.setTitle("My RSS feed"); diff --git a/src/main/java/org/springframework/samples/mvc/response/ResponseController.java b/src/main/java/org/springframework/samples/mvc/response/ResponseController.java index 8a36bcfda..ef95195ac 100644 --- a/src/main/java/org/springframework/samples/mvc/response/ResponseController.java +++ b/src/main/java/org/springframework/samples/mvc/response/ResponseController.java @@ -4,28 +4,27 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; -@Controller +@RestController @RequestMapping(value="/response", method=RequestMethod.GET) public class ResponseController { @GetMapping("/annotation") - public @ResponseBody String responseBody() { + public String responseBody() { return "The String ResponseBody"; } @GetMapping("/charset/accept") - public @ResponseBody String responseAcceptHeaderCharset() { + public String responseAcceptHeaderCharset() { return "\u3053\u3093\u306b\u3061\u306f\u4e16\u754c\uff01 (\"Hello world!\" in Japanese)"; } @GetMapping(value="/charset/produce", produces="text/plain;charset=UTF-8") - public @ResponseBody String responseProducesConditionCharset() { + public String responseProducesConditionCharset() { return "\u3053\u3093\u306b\u3061\u306f\u4e16\u754c\uff01 (\"Hello world!\" in Japanese)"; } diff --git a/src/main/java/org/springframework/samples/mvc/simple/SimpleController.java b/src/main/java/org/springframework/samples/mvc/simple/SimpleController.java index fc3975152..7c9bfa278 100644 --- a/src/main/java/org/springframework/samples/mvc/simple/SimpleController.java +++ b/src/main/java/org/springframework/samples/mvc/simple/SimpleController.java @@ -1,14 +1,13 @@ package org.springframework.samples.mvc.simple; -import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; -@Controller +@RestController public class SimpleController { @GetMapping("/simple") - public @ResponseBody String simple() { + public String simple() { return "Hello world!"; } diff --git a/src/main/java/org/springframework/samples/mvc/simple/SimpleControllerRevisited.java b/src/main/java/org/springframework/samples/mvc/simple/SimpleControllerRevisited.java index 3430388e8..fb9889ce4 100644 --- a/src/main/java/org/springframework/samples/mvc/simple/SimpleControllerRevisited.java +++ b/src/main/java/org/springframework/samples/mvc/simple/SimpleControllerRevisited.java @@ -1,14 +1,13 @@ package org.springframework.samples.mvc.simple; -import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; -@Controller +@RestController public class SimpleControllerRevisited { @GetMapping(path="/simple/revisited", headers="Accept=text/plain") - public @ResponseBody String simple() { + public String simple() { return "Hello world revisited!"; } diff --git a/src/main/java/org/springframework/samples/mvc/validation/ValidationController.java b/src/main/java/org/springframework/samples/mvc/validation/ValidationController.java index edb1a882f..4a916d5b7 100644 --- a/src/main/java/org/springframework/samples/mvc/validation/ValidationController.java +++ b/src/main/java/org/springframework/samples/mvc/validation/ValidationController.java @@ -5,8 +5,9 @@ import org.springframework.stereotype.Controller; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; -@Controller +@RestController public class ValidationController { // enforcement of constraints on the JavaBean arg require a JSR-303 provider on the classpath From 5f2ff0dfd80979b974241ed8c9981950b307f920 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Mon, 19 Mar 2018 14:51:09 -0400 Subject: [PATCH 25/31] Update SFW version to 5.0.4 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ccd8ca5ce..6be8eb953 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ 1.8 - 5.0.3.RELEASE + 5.0.4.RELEASE 1.8.1 From b9e18ad9e508409324b8afa9d359cfe05cd8442e Mon Sep 17 00:00:00 2001 From: "Daniel J. Brieck Jr" Date: Wed, 30 May 2018 20:04:39 -0500 Subject: [PATCH 26/31] Checking in clarification note with location of controller code for standard and custom web Arguments --- src/main/webapp/WEB-INF/views/home.jsp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/webapp/WEB-INF/views/home.jsp b/src/main/webapp/WEB-INF/views/home.jsp index 8e0fe94f2..819a614b4 100644 --- a/src/main/webapp/WEB-INF/views/home.jsp +++ b/src/main/webapp/WEB-INF/views/home.jsp @@ -131,6 +131,9 @@

Standard Resolvable Web Arguments

+

+ See the org.springframework.samples.mvc.data.standard package for the @Controller code +

Custom Resolvable Web Arguments

+

+ See the org.springframework.samples.mvc.data.custom package for the @Controller code +

  • ">Custom @@ -647,4 +653,4 @@ $(document).ready(function() { }); - \ No newline at end of file + From 5d869f531e93af36a17789419d0cc90d90840feb Mon Sep 17 00:00:00 2001 From: Spring Operator Date: Wed, 20 Mar 2019 20:13:29 -0500 Subject: [PATCH 27/31] URL Cleanup This commit updates URLs to prefer the https protocol. Redirects are not followed to avoid accidentally expanding intentionally shortened URLs (i.e. if using a URL shortener). # HTTP URLs that Could Not Be Fixed These URLs were unable to be fixed. Please review them to see if they can be manually resolved. * [ ] http://erik.eae.net/archives/2007/07/27/18.54.15/ (200) with 1 occurrences could not be migrated: ([https](https://erik.eae.net/archives/2007/07/27/18.54.15/) result SSLHandshakeException). * [ ] http://javascript.nwbox.com/IEContentLoaded/ (200) with 1 occurrences could not be migrated: ([https](https://javascript.nwbox.com/IEContentLoaded/) result SSLHandshakeException). * [ ] http://malsup.com/jquery/form/ (200) with 1 occurrences could not be migrated: ([https](https://malsup.com/jquery/form/) result SSLHandshakeException). * [ ] http://s3.springsource.org/MVC/mvc-showcase-screencast.mov (200) with 1 occurrences could not be migrated: ([https](https://s3.springsource.org/MVC/mvc-showcase-screencast.mov) result SSLHandshakeException). * [ ] http://blindsignals.com/index.php/2009/07/jquery-delay/ (301) with 1 occurrences could not be migrated: ([https](https://blindsignals.com/index.php/2009/07/jquery-delay/) result SSLHandshakeException). # Fixed URLs ## Fixed But Review Recommended These URLs were fixed, but the https status was not OK. However, the https status was the same as the http request or http redirected to an https URL, so they were migrated. Your review is recommended. * [ ] http://dev.jquery.com/ticket/2752 (UnknownHostException) with 1 occurrences migrated to: https://dev.jquery.com/ticket/2752 ([https](https://dev.jquery.com/ticket/2752) result UnknownHostException). * [ ] http://dev.jquery.com/ticket/4014 (UnknownHostException) with 1 occurrences migrated to: https://dev.jquery.com/ticket/4014 ([https](https://dev.jquery.com/ticket/4014) result UnknownHostException). * [ ] http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/ (UnknownHostException) with 1 occurrences migrated to: https://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/ ([https](https://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/) result UnknownHostException). * [ ] http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ (301) with 1 occurrences migrated to: https://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ ([https](https://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/) result 404). * [ ] http://json.org/json2.js (404) with 1 occurrences migrated to: https://json.org/json2.js ([https](https://json.org/json2.js) result 404). * [ ] http://www.JSON.org/js.html (404) with 1 occurrences migrated to: https://www.JSON.org/js.html ([https](https://www.JSON.org/js.html) result 404). * [ ] http://www.JSON.org/json2.js (404) with 1 occurrences migrated to: https://www.JSON.org/json2.js ([https](https://www.JSON.org/json2.js) result 404). ## Fixed Success These URLs were switched to an https URL with a 2xx status. While the status was successful, your review is still recommended. * [ ] http://docs.spring.io/spring-security/site/docs/3.2.x/reference/htmlsingle/ with 2 occurrences migrated to: https://docs.spring.io/spring-security/site/docs/3.2.x/reference/htmlsingle/ ([https](https://docs.spring.io/spring-security/site/docs/3.2.x/reference/htmlsingle/) result 200). * [ ] http://docs.spring.io/spring-security/site/docs/current/reference/htmlsingle/ with 1 occurrences migrated to: https://docs.spring.io/spring-security/site/docs/current/reference/htmlsingle/ ([https](https://docs.spring.io/spring-security/site/docs/current/reference/htmlsingle/) result 200). * [ ] http://jquery.com/ with 1 occurrences migrated to: https://jquery.com/ ([https](https://jquery.com/) result 200). * [ ] http://jqueryui.com/themeroller/ with 1 occurrences migrated to: https://jqueryui.com/themeroller/ ([https](https://jqueryui.com/themeroller/) result 200). * [ ] http://sizzlejs.com/ with 2 occurrences migrated to: https://sizzlejs.com/ ([https](https://sizzlejs.com/) result 200). * [ ] http://blog.springsource.com/2010/07/22/spring-mvc-3-showcase/ (301) with 1 occurrences migrated to: https://spring.io/blog/2010/07/22/spring-mvc-3-showcase/ ([https](https://blog.springsource.com/2010/07/22/spring-mvc-3-showcase/) result 200). * [ ] http://www.gnu.org/licenses/gpl.html with 1 occurrences migrated to: https://www.gnu.org/licenses/gpl.html ([https](https://www.gnu.org/licenses/gpl.html) result 200). * [ ] http://www.infoq.com/presentations/Mastering-Spring-MVC-3 with 1 occurrences migrated to: https://www.infoq.com/presentations/Mastering-Spring-MVC-3 ([https](https://www.infoq.com/presentations/Mastering-Spring-MVC-3) result 200). * [ ] http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html with 1 occurrences migrated to: https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html ([https](https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html) result 200). * [ ] http://code.google.com/p/v8/issues/detail?id=1050 with 1 occurrences migrated to: https://code.google.com/p/v8/issues/detail?id=1050 ([https](https://code.google.com/p/v8/issues/detail?id=1050) result 301). * [ ] http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d with 1 occurrences migrated to: https://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d ([https](https://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d) result 301). * [ ] http://help.github.com with 1 occurrences migrated to: https://help.github.com ([https](https://help.github.com) result 301). * [ ] http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_ with 1 occurrences migrated to: https://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_ ([https](https://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_) result 301). * [ ] http://jquery.org/license with 8 occurrences migrated to: https://jquery.org/license ([https](https://jquery.org/license) result 301). * [ ] http://jqueryui.com/about with 7 occurrences migrated to: https://jqueryui.com/about ([https](https://jqueryui.com/about) result 301). * [ ] http://www.opensource.org/licenses/mit-license.php with 1 occurrences migrated to: https://www.opensource.org/licenses/mit-license.php ([https](https://www.opensource.org/licenses/mit-license.php) result 301). * [ ] http://dev.jqueryui.com/ticket/3171 with 1 occurrences migrated to: https://dev.jqueryui.com/ticket/3171 ([https](https://dev.jqueryui.com/ticket/3171) result 302). * [ ] http://docs.jquery.com/Tutorials:Introducing_ with 1 occurrences migrated to: https://docs.jquery.com/Tutorials:Introducing_ ([https](https://docs.jquery.com/Tutorials:Introducing_) result 302). * [ ] http://docs.jquery.com/UI with 1 occurrences migrated to: https://docs.jquery.com/UI ([https](https://docs.jquery.com/UI) result 302). * [ ] http://docs.jquery.com/UI/API/1.8/Tabs with 1 occurrences migrated to: https://docs.jquery.com/UI/API/1.8/Tabs ([https](https://docs.jquery.com/UI/API/1.8/Tabs) result 302). * [ ] http://docs.jquery.com/UI/Tabs with 2 occurrences migrated to: https://docs.jquery.com/UI/Tabs ([https](https://docs.jquery.com/UI/Tabs) result 302). * [ ] http://docs.jquery.com/UI/Theming with 1 occurrences migrated to: https://docs.jquery.com/UI/Theming ([https](https://docs.jquery.com/UI/Theming) result 302). * [ ] http://docs.jquery.com/UI/Theming/API with 2 occurrences migrated to: https://docs.jquery.com/UI/Theming/API ([https](https://docs.jquery.com/UI/Theming/API) result 302). * [ ] http://docs.jquery.com/UI/Widget with 1 occurrences migrated to: https://docs.jquery.com/UI/Widget ([https](https://docs.jquery.com/UI/Widget) result 302). * [ ] http://docs.jquery.com/Utilities/jQuery.browser with 1 occurrences migrated to: https://docs.jquery.com/Utilities/jQuery.browser ([https](https://docs.jquery.com/Utilities/jQuery.browser) result 302). * [ ] http://javascript.crockford.com/jsmin.html with 1 occurrences migrated to: https://javascript.crockford.com/jsmin.html ([https](https://javascript.crockford.com/jsmin.html) result 302). * [ ] http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context with 1 occurrences migrated to: https://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context ([https](https://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context) result 302). # Ignored These URLs were intentionally ignored. * http://java.sun.com/jsp/jstl/core with 7 occurrences * http://localhost:8080/ with 1 occurrences * http://localhost:8080/mvc-showcase/rss with 2 occurrences * http://localhost:8080/spring-mvc-showcase/ with 1 occurrences * http://www.springframework.org/tags with 2 occurrences * http://www.springframework.org/tags/form with 1 occurrences * http://www.w3.org/2005/Atom with 2 occurrences * http://www.w3.org/TR/html4/interact/forms.html with 1 occurrences --- README.md | 4 +-- .../samples/mvc/config/RootConfig.java | 2 +- src/main/webapp/WEB-INF/views/fileupload.jsp | 2 +- src/main/webapp/WEB-INF/views/home.jsp | 4 +-- .../webapp/resources/jquery/1.6/jquery.js | 26 +++++++++---------- .../resources/jqueryform/2.8/jquery.form.js | 10 +++---- .../resources/jqueryui/1.8/jquery.ui.core.js | 8 +++--- .../resources/jqueryui/1.8/jquery.ui.tabs.js | 8 +++--- .../jqueryui/1.8/jquery.ui.widget.js | 6 ++--- .../1.8/themes/base/jquery.ui.all.css | 6 ++--- .../1.8/themes/base/jquery.ui.core.css | 6 ++--- .../1.8/themes/base/jquery.ui.tabs.css | 6 ++--- .../1.8/themes/base/jquery.ui.theme.css | 8 +++--- src/main/webapp/resources/json2.js | 6 ++--- 14 files changed, 51 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index 258cadc5a..de17e5232 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Clone the repository: $ git clone git://github.com/SpringSource/spring-mvc-showcase.git -If this is your first time using Github, review http://help.github.com to learn the basics. +If this is your first time using Github, review https://help.github.com to learn the basics. To run the application: ------------------- @@ -38,6 +38,6 @@ Access the deployed web application at: http://localhost:8080/spring-mvc-showcas Note: ------------------- -This showcase originated from a [blog post](http://blog.springsource.com/2010/07/22/spring-mvc-3-showcase/) and was adapted into a SpringOne presentation called [Mastering MVC 3](http://www.infoq.com/presentations/Mastering-Spring-MVC-3). +This showcase originated from a [blog post](https://spring.io/blog/2010/07/22/spring-mvc-3-showcase/) and was adapted into a SpringOne presentation called [Mastering MVC 3](https://www.infoq.com/presentations/Mastering-Spring-MVC-3). A screen cast showing the showcase in action is [available in QuickTime format](http://s3.springsource.org/MVC/mvc-showcase-screencast.mov). diff --git a/src/main/java/org/springframework/samples/mvc/config/RootConfig.java b/src/main/java/org/springframework/samples/mvc/config/RootConfig.java index b145f9031..449d95e7f 100644 --- a/src/main/java/org/springframework/samples/mvc/config/RootConfig.java +++ b/src/main/java/org/springframework/samples/mvc/config/RootConfig.java @@ -13,7 +13,7 @@ public class RootConfig { // CSRF protection. Here we only include the CsrfFilter instead of all of Spring Security. - // See http://docs.spring.io/spring-security/site/docs/current/reference/htmlsingle/#csrf + // See https://docs.spring.io/spring-security/site/docs/current/reference/htmlsingle/#csrf // for more information on Spring Security's CSRF protection @Bean diff --git a/src/main/webapp/WEB-INF/views/fileupload.jsp b/src/main/webapp/WEB-INF/views/fileupload.jsp index 05534b222..0b54e1d9b 100644 --- a/src/main/webapp/WEB-INF/views/fileupload.jsp +++ b/src/main/webapp/WEB-INF/views/fileupload.jsp @@ -16,7 +16,7 @@

    diff --git a/src/main/webapp/WEB-INF/views/home.jsp b/src/main/webapp/WEB-INF/views/home.jsp index 819a614b4..e8ed7f28d 100644 --- a/src/main/webapp/WEB-INF/views/home.jsp +++ b/src/main/webapp/WEB-INF/views/home.jsp @@ -501,7 +501,7 @@ $(document).ready(function() { // after a redirect or a full page refresh (e.g. Views tab). // However, note this general disclaimer about going back to previous tabs: - // http://docs.jquery.com/UI/API/1.8/Tabs#Back_button_and_bookmarking + // https://docs.jquery.com/UI/API/1.8/Tabs#Back_button_and_bookmarking $("#tabs").bind("tabsselect", function(event, ui) { window.location.hash = ui.tab.hash; }); @@ -643,7 +643,7 @@ $(document).ready(function() { }); // Include CSRF token as header in JQuery AJAX requests - // See http://docs.spring.io/spring-security/site/docs/3.2.x/reference/htmlsingle/#csrf-include-csrf-token-ajax + // See https://docs.spring.io/spring-security/site/docs/3.2.x/reference/htmlsingle/#csrf-include-csrf-token-ajax var token = $("meta[name='_csrf']").attr("content"); var header = $("meta[name='_csrf_header']").attr("content"); $(document).ajaxSend(function(e, xhr, options) { diff --git a/src/main/webapp/resources/jquery/1.6/jquery.js b/src/main/webapp/resources/jquery/1.6/jquery.js index 5d5a1d58e..0cd4ae733 100644 --- a/src/main/webapp/resources/jquery/1.6/jquery.js +++ b/src/main/webapp/resources/jquery/1.6/jquery.js @@ -1,13 +1,13 @@ /*! * jQuery JavaScript Library v1.6.1 - * http://jquery.com/ + * https://jquery.com/ * * Copyright 2011, John Resig * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license + * https://jquery.org/license * * Includes Sizzle.js - * http://sizzlejs.com/ + * https://sizzlejs.com/ * Copyright 2011, The Dojo Foundation * Released under the MIT, BSD, and GPL Licenses. * @@ -554,7 +554,7 @@ jQuery.extend({ } // Make sure the incoming data is actual JSON - // Logic borrowed from http://json.org/json2.js + // Logic borrowed from https://json.org/json2.js if ( rvalidchars.test( data.replace( rvalidescape, "@" ) .replace( rvalidtokens, "]" ) .replace( rvalidbraces, "")) ) { @@ -591,7 +591,7 @@ jQuery.extend({ // Evaluates a script in a global context // Workarounds based on findings by Jim Driscoll - // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context + // https://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context globalEval: function( data ) { if ( data && rnotwhite.test( data ) ) { // We use execScript on Internet Explorer @@ -832,7 +832,7 @@ jQuery.extend({ }, // Use of jQuery.browser is frowned upon. - // More details: http://docs.jquery.com/Utilities/jQuery.browser + // More details: https://docs.jquery.com/Utilities/jQuery.browser uaMatch: function( ua ) { ua = ua.toLowerCase(); @@ -1348,7 +1348,7 @@ jQuery.support = (function() { documentElement.removeChild( body ); // Technique from Juriy Zaytsev - // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/ + // https://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/ // We only care about the case where non-standard event systems // are used, namely in IE. Short-circuiting here helps us to // avoid an eval call (in setAttribute) which can cause CSP @@ -1822,7 +1822,7 @@ jQuery.fn.extend({ }); }, // Based off of the plugin by Clint Helfers, with permission. - // http://blindsignals.com/index.php/2009/07/jquery-delay/ + // http://blindsignals.com delay: function( time, type ) { time = jQuery.fx ? jQuery.fx.speeds[time] || time : time; type = type || "fx"; @@ -2273,7 +2273,7 @@ jQuery.extend({ tabIndex: { get: function( elem ) { // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set - // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ + // https://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ var attributeNode = elem.getAttributeNode("tabIndex"); return attributeNode && attributeNode.specified ? @@ -3099,7 +3099,7 @@ function returnTrue() { } // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding -// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html +// https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html jQuery.Event.prototype = { preventDefault: function() { this.isDefaultPrevented = returnTrue; @@ -3701,7 +3701,7 @@ jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblcl * Sizzle CSS Selector Engine * Copyright 2011, The Dojo Foundation * Released under the MIT, BSD, and GPL Licenses. - * More information: http://sizzlejs.com/ + * More information: https://sizzlejs.com/ */ (function(){ @@ -5343,7 +5343,7 @@ jQuery.each({ // The variable 'args' was introduced in // https://github.com/jquery/jquery/commit/52a0238 // to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed. - // http://code.google.com/p/v8/issues/detail?id=1050 + // https://code.google.com/p/v8/issues/detail?id=1050 args = slice.call(arguments); if ( !runtil.test( name ) ) { @@ -7839,7 +7839,7 @@ if ( jQuery.support.ajax ) { // Firefox throws exceptions when accessing properties // of an xhr when a network error occured - // http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE) + // https://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE) try { // Was never called and is aborted or complete diff --git a/src/main/webapp/resources/jqueryform/2.8/jquery.form.js b/src/main/webapp/resources/jqueryform/2.8/jquery.form.js index baf8b1637..35a8b43bc 100644 --- a/src/main/webapp/resources/jqueryform/2.8/jquery.form.js +++ b/src/main/webapp/resources/jqueryform/2.8/jquery.form.js @@ -5,8 +5,8 @@ * * Examples and documentation at: http://malsup.com/jquery/form/ * Dual licensed under the MIT and GPL licenses: - * http://www.opensource.org/licenses/mit-license.php - * http://www.gnu.org/licenses/gpl.html + * https://www.opensource.org/licenses/mit-license.php + * https://www.gnu.org/licenses/gpl.html */ ;(function($) { @@ -44,7 +44,7 @@ * an HTML form using AJAX. */ $.fn.ajaxSubmit = function(options) { - // fast fail if nothing selected (http://dev.jquery.com/ticket/2752) + // fast fail if nothing selected (https://dev.jquery.com/ticket/2752) if (!this.length) { log('ajaxSubmit: skipping submit process - no element selected'); return this; @@ -160,7 +160,7 @@ $.fn.ajaxSubmit = function(options) { // 06-NOV-09: now defaulting to iframe mode if file input is detected if (options.iframe !== false && (fileInputs || options.iframe || multipart)) { // hack to fix Safari hang (thanks to Tim Molendijk for this) - // see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d + // see: https://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d if (options.closeKeepAlive) { $.get(options.closeKeepAlive, function() { fileUpload(a); }); } @@ -534,7 +534,7 @@ $.fn.ajaxForm = function(options) { }); return this; } - // is your DOM ready? http://docs.jquery.com/Tutorials:Introducing_$(document).ready() + // is your DOM ready? https://docs.jquery.com/Tutorials:Introducing_$(document).ready() log('terminating; zero elements found by selector' + ($.isReady ? '' : ' (DOM not ready)')); return this; } diff --git a/src/main/webapp/resources/jqueryui/1.8/jquery.ui.core.js b/src/main/webapp/resources/jqueryui/1.8/jquery.ui.core.js index b175bd407..42de01454 100644 --- a/src/main/webapp/resources/jqueryui/1.8/jquery.ui.core.js +++ b/src/main/webapp/resources/jqueryui/1.8/jquery.ui.core.js @@ -1,11 +1,11 @@ /*! * jQuery UI 1.8.13 * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) + * Copyright 2011, AUTHORS.txt (https://jqueryui.com/about) * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license + * https://jquery.org/license * - * http://docs.jquery.com/UI + * https://docs.jquery.com/UI */ (function( $, undefined ) { @@ -234,7 +234,7 @@ $(function() { $.support.selectstart = "onselectstart" in div; // set display to none to avoid a layout bug in IE - // http://dev.jquery.com/ticket/4014 + // https://dev.jquery.com/ticket/4014 body.removeChild( div ).style.display = "none"; }); diff --git a/src/main/webapp/resources/jqueryui/1.8/jquery.ui.tabs.js b/src/main/webapp/resources/jqueryui/1.8/jquery.ui.tabs.js index 6a2dec158..77f6c0933 100644 --- a/src/main/webapp/resources/jqueryui/1.8/jquery.ui.tabs.js +++ b/src/main/webapp/resources/jqueryui/1.8/jquery.ui.tabs.js @@ -1,11 +1,11 @@ /* * jQuery UI Tabs 1.8.13 * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) + * Copyright 2011, AUTHORS.txt (https://jqueryui.com/about) * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license + * https://jquery.org/license * - * http://docs.jquery.com/UI/Tabs + * https://docs.jquery.com/UI/Tabs * * Depends: * jquery.ui.core.js @@ -380,7 +380,7 @@ $.widget( "ui.tabs", { showTab( el, $show ); }); - // TODO make passing in node possible, see also http://dev.jqueryui.com/ticket/3171 + // TODO make passing in node possible, see also https://dev.jqueryui.com/ticket/3171 self.load( self.anchors.index( this ) ); this.blur(); diff --git a/src/main/webapp/resources/jqueryui/1.8/jquery.ui.widget.js b/src/main/webapp/resources/jqueryui/1.8/jquery.ui.widget.js index 77ae17729..a8fb3757f 100644 --- a/src/main/webapp/resources/jqueryui/1.8/jquery.ui.widget.js +++ b/src/main/webapp/resources/jqueryui/1.8/jquery.ui.widget.js @@ -1,11 +1,11 @@ /*! * jQuery UI Widget 1.8.13 * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) + * Copyright 2011, AUTHORS.txt (https://jqueryui.com/about) * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license + * https://jquery.org/license * - * http://docs.jquery.com/UI/Widget + * https://docs.jquery.com/UI/Widget */ (function( $, undefined ) { diff --git a/src/main/webapp/resources/jqueryui/1.8/themes/base/jquery.ui.all.css b/src/main/webapp/resources/jqueryui/1.8/themes/base/jquery.ui.all.css index 603aafd46..7126a84aa 100644 --- a/src/main/webapp/resources/jqueryui/1.8/themes/base/jquery.ui.all.css +++ b/src/main/webapp/resources/jqueryui/1.8/themes/base/jquery.ui.all.css @@ -1,11 +1,11 @@ /* * jQuery UI CSS Framework 1.8.13 * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) + * Copyright 2011, AUTHORS.txt (https://jqueryui.com/about) * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license + * https://jquery.org/license * - * http://docs.jquery.com/UI/Theming + * https://docs.jquery.com/UI/Theming */ @import "https://github.com/jquery.ui.base.css"; @import "https://github.com/jquery.ui.theme.css"; diff --git a/src/main/webapp/resources/jqueryui/1.8/themes/base/jquery.ui.core.css b/src/main/webapp/resources/jqueryui/1.8/themes/base/jquery.ui.core.css index ea82f08a8..d829fa3e6 100644 --- a/src/main/webapp/resources/jqueryui/1.8/themes/base/jquery.ui.core.css +++ b/src/main/webapp/resources/jqueryui/1.8/themes/base/jquery.ui.core.css @@ -1,11 +1,11 @@ /* * jQuery UI CSS Framework 1.8.13 * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) + * Copyright 2011, AUTHORS.txt (https://jqueryui.com/about) * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license + * https://jquery.org/license * - * http://docs.jquery.com/UI/Theming/API + * https://docs.jquery.com/UI/Theming/API */ /* Layout helpers diff --git a/src/main/webapp/resources/jqueryui/1.8/themes/base/jquery.ui.tabs.css b/src/main/webapp/resources/jqueryui/1.8/themes/base/jquery.ui.tabs.css index 1ed9c22d0..8d2c259fb 100644 --- a/src/main/webapp/resources/jqueryui/1.8/themes/base/jquery.ui.tabs.css +++ b/src/main/webapp/resources/jqueryui/1.8/themes/base/jquery.ui.tabs.css @@ -1,11 +1,11 @@ /* * jQuery UI Tabs 1.8.13 * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) + * Copyright 2011, AUTHORS.txt (https://jqueryui.com/about) * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license + * https://jquery.org/license * - * http://docs.jquery.com/UI/Tabs#theming + * https://docs.jquery.com/UI/Tabs#theming */ .ui-tabs { position: relative; padding: .2em; zoom: 1; } /* position: relative prevents IE scroll bug (element with position: relative inside container with overflow: auto appear as "fixed") */ .ui-tabs .ui-tabs-nav { margin: 0; padding: .2em .2em 0; } diff --git a/src/main/webapp/resources/jqueryui/1.8/themes/base/jquery.ui.theme.css b/src/main/webapp/resources/jqueryui/1.8/themes/base/jquery.ui.theme.css index c1018644e..7bac24115 100644 --- a/src/main/webapp/resources/jqueryui/1.8/themes/base/jquery.ui.theme.css +++ b/src/main/webapp/resources/jqueryui/1.8/themes/base/jquery.ui.theme.css @@ -1,13 +1,13 @@ /* * jQuery UI CSS Framework 1.8.13 * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) + * Copyright 2011, AUTHORS.txt (https://jqueryui.com/about) * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license + * https://jquery.org/license * - * http://docs.jquery.com/UI/Theming/API + * https://docs.jquery.com/UI/Theming/API * - * To view and modify this theme, visit http://jqueryui.com/themeroller/ + * To view and modify this theme, visit https://jqueryui.com/themeroller/ */ diff --git a/src/main/webapp/resources/json2.js b/src/main/webapp/resources/json2.js index a1a3b170c..8f5bc8a22 100644 --- a/src/main/webapp/resources/json2.js +++ b/src/main/webapp/resources/json2.js @@ -1,16 +1,16 @@ /* - http://www.JSON.org/json2.js + https://www.JSON.org/json2.js 2010-03-20 Public Domain. NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. - See http://www.JSON.org/js.html + See https://www.JSON.org/js.html This code should be minified before deployment. - See http://javascript.crockford.com/jsmin.html + See https://javascript.crockford.com/jsmin.html USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO NOT CONTROL. From 36e92784e46ff9e6e9eb43e0bac18dd7f6fa8dbd Mon Sep 17 00:00:00 2001 From: Spring Operator Date: Tue, 19 Mar 2019 22:42:22 -0500 Subject: [PATCH 28/31] URL Cleanup This commit updates URLs to prefer the https protocol. Redirects are not followed to avoid accidentally expanding intentionally shortened URLs (i.e. if using a URL shortener). # Fixed URLs ## Fixed Success These URLs were switched to an https URL with a 2xx status. While the status was successful, your review is still recommended. * http://maven.apache.org/maven-v4_0_0.xsd with 1 occurrences migrated to: https://maven.apache.org/maven-v4_0_0.xsd ([https](https://maven.apache.org/maven-v4_0_0.xsd) result 301). # Ignored These URLs were intentionally ignored. * http://maven.apache.org/POM/4.0.0 with 2 occurrences * http://www.w3.org/2001/XMLSchema-instance with 1 occurrences --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6be8eb953..900d42021 100644 --- a/pom.xml +++ b/pom.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0%20https://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 org.springframework.samples spring-mvc-showcase From fa09f61c31c8dc525154d77d8b0317df1766740a Mon Sep 17 00:00:00 2001 From: chris-bailey Date: Tue, 31 Mar 2015 21:35:33 -0400 Subject: [PATCH 29/31] Typo fix home.jsp --- src/main/webapp/WEB-INF/views/home.jsp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/webapp/WEB-INF/views/home.jsp b/src/main/webapp/WEB-INF/views/home.jsp index e8ed7f28d..c450135db 100644 --- a/src/main/webapp/WEB-INF/views/home.jsp +++ b/src/main/webapp/WEB-INF/views/home.jsp @@ -84,7 +84,7 @@ ">By produces via Accept=application/json
  • - ">By produces via Accept=appilcation/xml + ">By produces via Accept=application/xml
  • ">By produces via ".json" From 1711abff87f66bd65dec01f5d428ebe080b39057 Mon Sep 17 00:00:00 2001 From: Trevor Marshall Date: Fri, 4 Feb 2022 15:33:14 -0800 Subject: [PATCH 30/31] Add license LICENSE --- LICENSE | 205 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 205 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..a3339d120 --- /dev/null +++ b/LICENSE @@ -0,0 +1,205 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2015-Present Pivotal Software Inc. + + 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. + + + From 71d8c7e3432b226f09092dd13a7cfe2298fdd265 Mon Sep 17 00:00:00 2001 From: Trevor Marshall Date: Fri, 4 Feb 2022 15:36:02 -0800 Subject: [PATCH 31/31] Add archive text to README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index de17e5232..1b9da2dbb 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +# spring-mvc-showcase is no longer actively maintained by VMware, Inc. + Spring MVC Showcase ------------------- Demonstrates the capabilities of the Spring MVC web framework through small, simple examples.