Skip to content

Commit e84b7b0

Browse files
author
Yuki YOSHIDA
committed
support spring-data-commons 3.x
1 parent db642b7 commit e84b7b0

File tree

2 files changed

+18
-25
lines changed

2 files changed

+18
-25
lines changed

pom.xml

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,22 @@
3333

3434
<properties>
3535
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
36+
<java.version>17</java.version>
37+
<maven.compiler.source>17</maven.compiler.source>
38+
<maven.compiler.target>17</maven.compiler.target>
3639
</properties>
3740

3841
<build>
3942
<plugins>
4043
<plugin>
4144
<groupId>org.apache.maven.plugins</groupId>
4245
<artifactId>maven-compiler-plugin</artifactId>
43-
<version>3.3</version>
44-
<configuration>
45-
<source>1.6</source>
46-
<target>1.6</target>
47-
</configuration>
46+
<version>3.8.1</version>
4847
</plugin>
4948
<plugin>
5049
<groupId>org.apache.maven.plugins</groupId>
5150
<artifactId>maven-source-plugin</artifactId>
52-
<version>3.0.1</version>
51+
<version>3.2.1</version>
5352
<executions>
5453
<execution>
5554
<id>attach-sources</id>
@@ -62,7 +61,7 @@
6261
<plugin>
6362
<groupId>org.apache.maven.plugins</groupId>
6463
<artifactId>maven-javadoc-plugin</artifactId>
65-
<version>3.0.1</version>
64+
<version>3.3.0</version>
6665
<executions>
6766
<execution>
6867
<id>attach-javadocs</id>
@@ -90,21 +89,15 @@
9089
</build>
9190

9291
<dependencies>
93-
<dependency>
94-
<groupId>javax.servlet</groupId>
95-
<artifactId>servlet-api</artifactId>
96-
<version>2.4</version>
97-
<scope>provided</scope>
98-
</dependency>
9992
<dependency>
10093
<groupId>org.springframework.data</groupId>
10194
<artifactId>spring-data-commons</artifactId>
102-
<version>2.6.0</version>
95+
<version>3.0.0</version>
10396
</dependency>
10497
<dependency>
10598
<groupId>org.thymeleaf</groupId>
10699
<artifactId>thymeleaf</artifactId>
107-
<version>3.0.14.RELEASE</version>
100+
<version>3.1.1.RELEASE</version>
108101
</dependency>
109102
</dependencies>
110103

src/main/java/org/thymeleaf/dialect/springdata/util/PageUtils.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,11 @@
1111

1212
import java.util.Arrays;
1313
import java.util.Collection;
14-
import java.util.Enumeration;
1514
import java.util.Iterator;
1615
import java.util.Map;
1716
import java.util.Map.Entry;
1817
import java.util.Set;
1918

20-
import javax.servlet.http.HttpServletRequest;
21-
2219
import org.springframework.data.domain.Page;
2320
import org.springframework.data.domain.Sort;
2421
import org.springframework.data.domain.Sort.Direction;
@@ -31,6 +28,8 @@
3128
import org.thymeleaf.standard.expression.IStandardExpression;
3229
import org.thymeleaf.standard.expression.IStandardExpressionParser;
3330
import org.thymeleaf.standard.expression.StandardExpressions;
31+
import org.thymeleaf.web.IWebExchange;
32+
import org.thymeleaf.web.IWebRequest;
3433
import org.unbescape.html.HtmlEscape;
3534

3635
@SuppressWarnings("unchecked")
@@ -60,12 +59,12 @@ public static Page<?> findPage(final ITemplateContext context) {
6059

6160
// Search for Page object, and only one instance, as request attribute
6261
if (context instanceof IWebContext) {
63-
HttpServletRequest request = ((IWebContext) context).getRequest();
64-
Enumeration<String> attrNames = request.getAttributeNames();
62+
IWebExchange webExchange = ((IWebContext) context).getExchange();
63+
Set<String> attrNames = webExchange.getAllAttributeNames();
6564
Page<?> pageOnRequest = null;
66-
while (attrNames.hasMoreElements()) {
67-
String attrName = (String) attrNames.nextElement();
68-
Object attr = request.getAttribute(attrName);
65+
66+
for (String attrName : attrNames) {
67+
Object attr = webExchange.getAttributeValue(attrName);
6968
if (isPageInstance(attr)) {
7069
if (pageOnRequest != null) {
7170
throw new InvalidObjectParameterException("More than one Page object found on request!");
@@ -162,10 +161,11 @@ private static String buildBaseUrl(final ITemplateContext context, Collection<St
162161
// Creates url from actual request URI and parameters
163162
final StringBuilder builder = new StringBuilder();
164163
final IWebContext webContext = (IWebContext) context;
165-
final HttpServletRequest request = webContext.getRequest();
164+
final IWebExchange webExchange = webContext.getExchange();
165+
final IWebRequest request = webExchange.getRequest();
166166

167167
// URL base path from request
168-
builder.append(request.getRequestURI());
168+
builder.append(request.getRequestURL());
169169

170170
Map<String, String[]> params = request.getParameterMap();
171171
Set<Entry<String, String[]>> entries = params.entrySet();

0 commit comments

Comments
 (0)