Skip to content

Commit ea69e35

Browse files
Merge branch '3.1.x'
2 parents d759eb5 + f9b321c commit ea69e35

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

spring-session-samples/spring-session-sample-boot-redis-json/src/main/java/sample/web/HomeController.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@
1616

1717
package sample.web;
1818

19+
import java.util.Collections;
20+
1921
import jakarta.servlet.http.HttpServletRequest;
2022

2123
import org.springframework.stereotype.Controller;
24+
import org.springframework.ui.Model;
2225
import org.springframework.util.ObjectUtils;
2326
import org.springframework.web.bind.annotation.RequestMapping;
2427
import org.springframework.web.bind.annotation.RequestParam;
@@ -31,10 +34,11 @@ public class HomeController {
3134

3235
@RequestMapping("/setValue")
3336
public String setValue(@RequestParam(name = "key", required = false) String key,
34-
@RequestParam(name = "value", required = false) String value, HttpServletRequest request) {
37+
@RequestParam(name = "value", required = false) String value, HttpServletRequest request, Model model) {
3538
if (!ObjectUtils.isEmpty(key) && !ObjectUtils.isEmpty(value)) {
3639
request.getSession().setAttribute(key, value);
3740
}
41+
model.addAttribute("sessionAttributeNames", Collections.list(request.getSession().getAttributeNames()));
3842
return "home";
3943
}
4044

spring-session-samples/spring-session-sample-boot-redis-json/src/main/resources/templates/home.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
</tr>
2424
</thead>
2525
<tbody>
26-
<tr th:each="name : ${T(org.springframework.util.CollectionUtils).toIterator(httpSession?.getAttributeNames())}">
26+
<tr th:each="name : ${sessionAttributeNames}">
2727
<td th:text="${name}"></td>
2828
<td th:text="${httpSession.getAttribute(name)}"></td>
2929
</tr>

0 commit comments

Comments
 (0)