Merge pull request #3798 from chrisoberle/master
BAEL-1533 Making a Spring MVC Form Remember Values
This commit is contained in:
commit
9bbbe5446f
3
pom.xml
3
pom.xml
@ -200,7 +200,8 @@
|
|||||||
<module>spring-ldap</module>
|
<module>spring-ldap</module>
|
||||||
<module>spring-mockito</module>
|
<module>spring-mockito</module>
|
||||||
<module>spring-mvc-email</module>
|
<module>spring-mvc-email</module>
|
||||||
<module>spring-mvc-forms</module>
|
<module>spring-mvc-forms-jsp</module>
|
||||||
|
<module>spring-mvc-forms-thymeleaf</module>
|
||||||
<module>spring-mvc-java</module>
|
<module>spring-mvc-java</module>
|
||||||
<module>spring-mvc-tiles</module>
|
<module>spring-mvc-tiles</module>
|
||||||
<module>spring-mvc-velocity</module>
|
<module>spring-mvc-velocity</module>
|
||||||
|
@ -43,10 +43,6 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-hateoas</artifactId>
|
<artifactId>spring-boot-starter-hateoas</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectreactor</groupId>
|
<groupId>org.projectreactor</groupId>
|
||||||
<artifactId>reactor-spring</artifactId>
|
<artifactId>reactor-spring</artifactId>
|
||||||
@ -56,6 +52,18 @@
|
|||||||
<groupId>javax.json.bind</groupId>
|
<groupId>javax.json.bind</groupId>
|
||||||
<artifactId>javax.json.bind-api</artifactId>
|
<artifactId>javax.json.bind-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- Dependencies for Yasson -->
|
||||||
|
<!-- <dependency> -->
|
||||||
|
<!-- <groupId>org.eclipse</groupId> -->
|
||||||
|
<!-- <artifactId>yasson</artifactId> -->
|
||||||
|
<!-- <version>1.0</version> -->
|
||||||
|
<!-- </dependency> -->
|
||||||
|
<!-- <dependency> -->
|
||||||
|
<!-- <groupId>org.glassfish</groupId> -->
|
||||||
|
<!-- <artifactId>javax.json</artifactId> -->
|
||||||
|
<!-- <version>1.1.2</version> -->
|
||||||
|
<!-- </dependency> -->
|
||||||
|
<!-- Dependencies for Johnzon -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.geronimo.specs</groupId>
|
<groupId>org.apache.geronimo.specs</groupId>
|
||||||
<artifactId>geronimo-json_1.1_spec</artifactId>
|
<artifactId>geronimo-json_1.1_spec</artifactId>
|
||||||
@ -64,7 +72,6 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.johnzon</groupId>
|
<groupId>org.apache.johnzon</groupId>
|
||||||
<artifactId>johnzon-jsonb</artifactId>
|
<artifactId>johnzon-jsonb</artifactId>
|
||||||
<version>${johnzon.version}</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- utils -->
|
<!-- utils -->
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -205,8 +212,8 @@
|
|||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
<junit.platform.version>1.0.0</junit.platform.version>
|
<junit.platform.version>1.0.0</junit.platform.version>
|
||||||
<maven-surefire-plugin.version>2.20</maven-surefire-plugin.version>
|
<maven-surefire-plugin.version>2.20</maven-surefire-plugin.version>
|
||||||
|
<spring.version>5.0.2.RELEASE</spring.version>
|
||||||
<reactor-spring.version>1.0.1.RELEASE</reactor-spring.version>
|
<reactor-spring.version>1.0.1.RELEASE</reactor-spring.version>
|
||||||
<johnzon.version>1.1.3</johnzon.version>
|
|
||||||
<geronimo-json_1.1_spec.version>1.0</geronimo-json_1.1_spec.version>
|
<geronimo-json_1.1_spec.version>1.0</geronimo-json_1.1_spec.version>
|
||||||
<asciidoctor-plugin.version>1.5.6</asciidoctor-plugin.version>
|
<asciidoctor-plugin.version>1.5.6</asciidoctor-plugin.version>
|
||||||
<snippetsDirectory>${project.build.directory}/generated-snippets</snippetsDirectory>
|
<snippetsDirectory>${project.build.directory}/generated-snippets</snippetsDirectory>
|
||||||
|
@ -6,9 +6,9 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<version>0.1-SNAPSHOT</version>
|
<version>0.1-SNAPSHOT</version>
|
||||||
<artifactId>spring-mvc-forms</artifactId>
|
<artifactId>spring-mvc-forms-jsp</artifactId>
|
||||||
|
|
||||||
<name>spring-mvc-forms</name>
|
<name>spring-mvc-forms-jsp</name>
|
||||||
<packaging>war</packaging>
|
<packaging>war</packaging>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
73
spring-mvc-forms-thymeleaf/pom.xml
Normal file
73
spring-mvc-forms-thymeleaf/pom.xml
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>com.baeldung</groupId>
|
||||||
|
<artifactId>spring-mvc-forms-thymeleaf</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<name>spring-mvc-forms-thymeleaf</name>
|
||||||
|
<description>spring forms examples using thymeleaf</description>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
|
<version>2.0.0.RELEASE</version>
|
||||||
|
<relativePath /> <!-- lookup parent from repository -->
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- runtime and test scoped -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-devtools</artifactId>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<forkCount>3</forkCount>
|
||||||
|
<reuseForks>true</reuseForks>
|
||||||
|
<parallel>methods</parallel>
|
||||||
|
<useUnlimitedThreads>true</useUnlimitedThreads>
|
||||||
|
<excludes>
|
||||||
|
<exclude>**/*IntegrationTest.java</exclude>
|
||||||
|
<exclude>**/*LiveTest.java</exclude>
|
||||||
|
</excludes>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
</project>
|
@ -0,0 +1,3 @@
|
|||||||
|
server.port=8081
|
||||||
|
|
||||||
|
logging.level.root=INFO
|
@ -1,7 +1,7 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4" lang="en">
|
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4" lang="en">
|
||||||
<head>
|
<head>
|
||||||
<title>Session Scope in Spring MVC</title>
|
<title>Session Attributes in Spring MVC</title>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
<meta name="description" content="">
|
<meta name="description" content="">
|
@ -1,7 +1,7 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4" lang="en">
|
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4" lang="en">
|
||||||
<head>
|
<head>
|
||||||
<title>Session Scope in Spring MVC</title>
|
<title>Session Attributes in Spring MVC</title>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
<meta name="description" content="">
|
<meta name="description" content="">
|
@ -1,7 +1,7 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4" lang="en">
|
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4" lang="en">
|
||||||
<head>
|
<head>
|
||||||
<title>Session Scope in Spring MVC</title>
|
<title>Session Attributes in Spring MVC</title>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
<meta name="description" content="">
|
<meta name="description" content="">
|
@ -1,7 +1,7 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4" lang="en">
|
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4" lang="en">
|
||||||
<head>
|
<head>
|
||||||
<title>Session Scope in Spring MVC</title>
|
<title>Session Attributes in Spring MVC</title>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
<meta name="description" content="">
|
<meta name="description" content="">
|
@ -1,7 +1,7 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4" lang="en">
|
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4" lang="en">
|
||||||
<head>
|
<head>
|
||||||
<title>Session Scope in Spring MVC</title>
|
<title>Session Attributes in Spring MVC</title>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
<meta name="description" content="">
|
<meta name="description" content="">
|
@ -7,7 +7,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
|||||||
|
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
public class SessionAttrsApplicationIntegrationTest {
|
public class SessionAttrsApplicationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void contextLoads() {
|
public void contextLoads() {
|
@ -25,7 +25,7 @@ import org.springframework.web.context.WebApplicationContext;
|
|||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
@AutoConfigureMockMvc
|
@AutoConfigureMockMvc
|
||||||
@Import(TestConfig.class)
|
@Import(TestConfig.class)
|
||||||
public class TodoControllerWithScopedProxyIntegrationTest {
|
public class TodoControllerWithScopedProxyTest {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private MockMvc mockMvc;
|
private MockMvc mockMvc;
|
||||||
@ -40,7 +40,7 @@ public class TodoControllerWithScopedProxyIntegrationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenFirstRequest_thenContainsAllCategoriesAndUnintializedTodo() throws Exception {
|
public void whenFirstRequest_thenContainsUnintializedTodo() throws Exception {
|
||||||
MvcResult result = mockMvc.perform(get("/scopedproxy/form"))
|
MvcResult result = mockMvc.perform(get("/scopedproxy/form"))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(model().attributeExists("todo"))
|
.andExpect(model().attributeExists("todo"))
|
@ -24,7 +24,7 @@ import org.springframework.web.servlet.FlashMap;
|
|||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
@AutoConfigureMockMvc
|
@AutoConfigureMockMvc
|
||||||
public class TodoControllerWithSessionAttributesIntegrationTest {
|
public class TodoControllerWithSessionAttributesTest {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private MockMvc mockMvc;
|
private MockMvc mockMvc;
|
Loading…
x
Reference in New Issue
Block a user