|
11 | 11 |
|
12 | 12 | import java.util.Arrays; |
13 | 13 | import java.util.Collection; |
14 | | -import java.util.Enumeration; |
15 | 14 | import java.util.Iterator; |
16 | 15 | import java.util.Map; |
17 | 16 | import java.util.Map.Entry; |
18 | 17 | import java.util.Set; |
19 | 18 |
|
20 | | -import javax.servlet.http.HttpServletRequest; |
21 | | - |
22 | 19 | import org.springframework.data.domain.Page; |
23 | 20 | import org.springframework.data.domain.Sort; |
24 | 21 | import org.springframework.data.domain.Sort.Direction; |
|
31 | 28 | import org.thymeleaf.standard.expression.IStandardExpression; |
32 | 29 | import org.thymeleaf.standard.expression.IStandardExpressionParser; |
33 | 30 | import org.thymeleaf.standard.expression.StandardExpressions; |
| 31 | +import org.thymeleaf.web.IWebExchange; |
| 32 | +import org.thymeleaf.web.IWebRequest; |
34 | 33 | import org.unbescape.html.HtmlEscape; |
35 | 34 |
|
36 | 35 | @SuppressWarnings("unchecked") |
@@ -60,12 +59,12 @@ public static Page<?> findPage(final ITemplateContext context) { |
60 | 59 |
|
61 | 60 | // Search for Page object, and only one instance, as request attribute |
62 | 61 | 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(); |
65 | 64 | 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); |
69 | 68 | if (isPageInstance(attr)) { |
70 | 69 | if (pageOnRequest != null) { |
71 | 70 | throw new InvalidObjectParameterException("More than one Page object found on request!"); |
@@ -162,10 +161,11 @@ private static String buildBaseUrl(final ITemplateContext context, Collection<St |
162 | 161 | // Creates url from actual request URI and parameters |
163 | 162 | final StringBuilder builder = new StringBuilder(); |
164 | 163 | final IWebContext webContext = (IWebContext) context; |
165 | | - final HttpServletRequest request = webContext.getRequest(); |
| 164 | + final IWebExchange webExchange = webContext.getExchange(); |
| 165 | + final IWebRequest request = webExchange.getRequest(); |
166 | 166 |
|
167 | 167 | // URL base path from request |
168 | | - builder.append(request.getRequestURI()); |
| 168 | + builder.append(request.getRequestURL()); |
169 | 169 |
|
170 | 170 | Map<String, String[]> params = request.getParameterMap(); |
171 | 171 | Set<Entry<String, String[]>> entries = params.entrySet(); |
|
0 commit comments