Upgrade to latest Spring Session/Spring Boot
This commit is contained in:
@@ -34,6 +34,10 @@
|
||||
<groupId>de.flapdoodle.embed</groupId>
|
||||
<artifactId>de.flapdoodle.embed.mongo</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
||||
@@ -16,30 +16,16 @@
|
||||
|
||||
package org.springframework.session.mongodb.examples;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author Rob Winch
|
||||
* @author Greg Turnquist
|
||||
* @since 5.0
|
||||
*/
|
||||
@Data
|
||||
public class SessionAttributeForm {
|
||||
|
||||
private String attributeName;
|
||||
|
||||
private String attributeValue;
|
||||
|
||||
public String getAttributeName() {
|
||||
return this.attributeName;
|
||||
}
|
||||
|
||||
public void setAttributeName(String attributeName) {
|
||||
this.attributeName = attributeName;
|
||||
}
|
||||
|
||||
public String getAttributeValue() {
|
||||
return this.attributeValue;
|
||||
}
|
||||
|
||||
public void setAttributeValue(String attributeValue) {
|
||||
this.attributeValue = attributeValue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,12 +33,14 @@ public class SessionController {
|
||||
|
||||
@PostMapping("/session")
|
||||
public String setAttribute(@ModelAttribute SessionAttributeForm sessionAttributeForm, WebSession session) {
|
||||
|
||||
session.getAttributes().put(sessionAttributeForm.getAttributeName(), sessionAttributeForm.getAttributeValue());
|
||||
return "redirect:/";
|
||||
}
|
||||
|
||||
@GetMapping("/")
|
||||
public String index(Model model, WebSession webSession) {
|
||||
|
||||
model.addAttribute("webSession", webSession);
|
||||
return "index";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user