Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Kevin Gilmore 2017-02-10 07:31:47 -06:00
commit 46a73c7bea
96 changed files with 417 additions and 267 deletions

Binary file not shown.

View File

@ -11,7 +11,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version> <version>1.4.4.RELEASE</version>
</parent> </parent>

View File

@ -14,7 +14,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version> <version>1.4.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository --> <relativePath/> <!-- lookup parent from repository -->
</parent> </parent>

View File

@ -158,7 +158,7 @@
<module>spring-security-client/spring-security-thymeleaf-authorize</module> <module>spring-security-client/spring-security-thymeleaf-authorize</module>
<module>spring-security-client/spring-security-thymeleaf-config</module> <module>spring-security-client/spring-security-thymeleaf-config</module>
<module>spring-security-core</module> <module>spring-security-core</module>
<module>spring-security-custom-permission</module> <module>spring-security-mvc-boot</module>
<module>spring-security-mvc-custom</module> <module>spring-security-mvc-custom</module>
<module>spring-security-mvc-digest-auth</module> <module>spring-security-mvc-digest-auth</module>
<module>spring-security-mvc-ldap</module> <module>spring-security-mvc-ldap</module>

View File

@ -11,7 +11,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version> <version>1.4.4.RELEASE</version>
</parent> </parent>
<dependencies> <dependencies>

View File

@ -14,7 +14,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version> <version>1.4.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository --> <relativePath/> <!-- lookup parent from repository -->
</parent> </parent>

View File

@ -14,7 +14,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version> <version>1.4.4.RELEASE</version>
<relativePath /> <!-- lookup parent from repository --> <relativePath /> <!-- lookup parent from repository -->
</parent> </parent>

View File

@ -14,7 +14,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version> <version>1.4.4.RELEASE</version>
<relativePath /> <!-- lookup parent from repository --> <relativePath /> <!-- lookup parent from repository -->
</parent> </parent>

View File

@ -14,7 +14,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version> <version>1.4.4.RELEASE</version>
<relativePath /> <!-- lookup parent from repository --> <relativePath /> <!-- lookup parent from repository -->
</parent> </parent>

View File

@ -14,7 +14,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version> <version>1.4.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository --> <relativePath/> <!-- lookup parent from repository -->
</parent> </parent>

View File

@ -14,7 +14,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version> <version>1.4.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository --> <relativePath/> <!-- lookup parent from repository -->
</parent> </parent>

View File

@ -10,7 +10,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version> <version>1.4.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository --> <relativePath/> <!-- lookup parent from repository -->
</parent> </parent>

View File

@ -10,7 +10,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version> <version>1.4.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository --> <relativePath/> <!-- lookup parent from repository -->
</parent> </parent>

View File

@ -10,7 +10,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version> <version>1.4.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository --> <relativePath/> <!-- lookup parent from repository -->
</parent> </parent>

View File

@ -11,7 +11,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version> <version>1.4.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository --> <relativePath/> <!-- lookup parent from repository -->
</parent> </parent>

View File

@ -11,7 +11,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version> <version>1.4.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository --> <relativePath/> <!-- lookup parent from repository -->
</parent> </parent>

View File

@ -16,7 +16,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version> <version>1.4.4.RELEASE</version>
<relativePath/> <relativePath/>
</parent> </parent>

View File

@ -11,7 +11,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version> <version>1.4.4.RELEASE</version>
<relativePath /> <!-- lookup parent from repository --> <relativePath /> <!-- lookup parent from repository -->
</parent> </parent>

View File

@ -14,7 +14,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version> <version>1.4.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository --> <relativePath/> <!-- lookup parent from repository -->
</parent> </parent>

View File

@ -11,7 +11,7 @@
<parent> <parent>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<version>1.4.2.RELEASE</version> <version>1.4.4.RELEASE</version>
<relativePath/> <relativePath/>
</parent> </parent>

View File

@ -14,7 +14,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version> <version>1.4.4.RELEASE</version>
<relativePath /> <!-- lookup parent from repository --> <relativePath /> <!-- lookup parent from repository -->
</parent> </parent>

View File

@ -1,215 +1,215 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <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"> 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> <modelVersion>4.0.0</modelVersion>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
<artifactId>jooq-spring</artifactId> <artifactId>jooq-spring</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>
<dependency> <dependency>
<!-- Import dependency management from Spring Boot --> <!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId> <artifactId>spring-boot-dependencies</artifactId>
<version>1.4.2.RELEASE</version> <version>1.4.4.RELEASE</version>
<type>pom</type> <type>pom</type>
<scope>import</scope> <scope>import</scope>
</dependency> </dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
<dependencies> <dependencies>
<!-- jOOQ --> <!-- jOOQ -->
<dependency> <dependency>
<groupId>org.jooq</groupId> <groupId>org.jooq</groupId>
<artifactId>jooq</artifactId> <artifactId>jooq</artifactId>
</dependency> </dependency>
<!-- Database Access --> <!-- Database Access -->
<dependency> <dependency>
<groupId>com.h2database</groupId> <groupId>com.h2database</groupId>
<artifactId>h2</artifactId> <artifactId>h2</artifactId>
</dependency> </dependency>
<!-- Spring --> <!-- Spring -->
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId> <artifactId>spring-context</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId> <artifactId>spring-jdbc</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jooq</artifactId> <artifactId>spring-boot-starter-jooq</artifactId>
</dependency> </dependency>
<!-- Logging --> <!-- Logging -->
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId> <artifactId>slf4j-api</artifactId>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>ch.qos.logback</groupId> <groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId> <artifactId>logback-classic</artifactId>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
<!-- Testing --> <!-- Testing -->
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId> <artifactId>spring-test</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
</dependency> </dependency>
</dependencies>
<build> </dependencies>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>${properties-maven-plugin.version}</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>src/main/resources/intro_config.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
<plugin> <build>
<groupId>org.codehaus.mojo</groupId> <plugins>
<artifactId>sql-maven-plugin</artifactId> <plugin>
<version>${sql-maven-plugin.version}</version> <groupId>org.codehaus.mojo</groupId>
<executions> <artifactId>properties-maven-plugin</artifactId>
<execution> <version>${properties-maven-plugin.version}</version>
<phase>initialize</phase> <executions>
<goals> <execution>
<goal>execute</goal> <phase>initialize</phase>
</goals> <goals>
<configuration> <goal>read-project-properties</goal>
<driver>${db.driver}</driver> </goals>
<url>${db.url}</url> <configuration>
<username>${db.username}</username> <files>
<password>${db.password}</password> <file>src/main/resources/intro_config.properties</file>
<srcFiles> </files>
<srcFile>src/main/resources/intro_schema.sql</srcFile> </configuration>
</srcFiles> </execution>
</configuration> </executions>
</execution> </plugin>
</executions>
<dependencies>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>${com.h2database.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin> <plugin>
<groupId>org.jooq</groupId> <groupId>org.codehaus.mojo</groupId>
<artifactId>jooq-codegen-maven</artifactId> <artifactId>sql-maven-plugin</artifactId>
<version>${org.jooq.version}</version> <version>${sql-maven-plugin.version}</version>
<executions> <executions>
<execution> <execution>
<phase>generate-sources</phase> <phase>initialize</phase>
<goals> <goals>
<goal>generate</goal> <goal>execute</goal>
</goals> </goals>
<configuration> <configuration>
<jdbc> <driver>${db.driver}</driver>
<driver>${db.driver}</driver> <url>${db.url}</url>
<url>${db.url}</url> <username>${db.username}</username>
<user>${db.username}</user> <password>${db.password}</password>
<password>${db.password}</password> <srcFiles>
</jdbc> <srcFile>src/main/resources/intro_schema.sql</srcFile>
<generator> </srcFiles>
<target> </configuration>
<packageName>com.baeldung.jooq.introduction.db</packageName> </execution>
<directory>src/main/java</directory> </executions>
</target> <dependencies>
</generator> <dependency>
</configuration> <groupId>com.h2database</groupId>
</execution> <artifactId>h2</artifactId>
</executions> <version>${com.h2database.version}</version>
</plugin> </dependency>
</dependencies>
</plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.jooq</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>jooq-codegen-maven</artifactId>
<version>${maven-compiler-plugin.version}</version> <version>${org.jooq.version}</version>
<configuration> <executions>
<source>1.8</source> <execution>
<target>1.8</target> <phase>generate-sources</phase>
</configuration> <goals>
</plugin> <goal>generate</goal>
</goals>
<configuration>
<jdbc>
<driver>${db.driver}</driver>
<url>${db.url}</url>
<user>${db.username}</user>
<password>${db.password}</password>
</jdbc>
<generator>
<target>
<packageName>com.baeldung.jooq.introduction.db</packageName>
<directory>src/main/java</directory>
</target>
</generator>
</configuration>
</execution>
</executions>
</plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<configuration> <version>${maven-compiler-plugin.version}</version>
<excludes> <configuration>
<exclude>**/*IntegrationTest.java</exclude> <source>1.8</source>
<exclude>**/*LiveTest.java</exclude> <target>1.8</target>
</excludes> </configuration>
</configuration> </plugin>
</plugin>
</plugins> <plugin>
<pluginManagement> <groupId>org.apache.maven.plugins</groupId>
<plugins> <artifactId>maven-surefire-plugin</artifactId>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.--> <configuration>
<plugin> <excludes>
<groupId>org.eclipse.m2e</groupId> <exclude>**/*IntegrationTest.java</exclude>
<artifactId>lifecycle-mapping</artifactId> <exclude>**/*LiveTest.java</exclude>
<version>${lifecycle-mapping.version}</version> </excludes>
<configuration> </configuration>
<lifecycleMappingMetadata> </plugin>
<pluginExecutions>
<pluginExecution> </plugins>
<pluginExecutionFilter> <pluginManagement>
<groupId>org.jooq</groupId> <plugins>
<artifactId> <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself. -->
jooq-codegen-maven <plugin>
</artifactId> <groupId>org.eclipse.m2e</groupId>
<versionRange> <artifactId>lifecycle-mapping</artifactId>
[3.7.3,) <version>${lifecycle-mapping.version}</version>
</versionRange> <configuration>
<goals> <lifecycleMappingMetadata>
<goal>generate</goal> <pluginExecutions>
</goals> <pluginExecution>
</pluginExecutionFilter> <pluginExecutionFilter>
<action> <groupId>org.jooq</groupId>
<ignore></ignore> <artifactId>
</action> jooq-codegen-maven
</pluginExecution> </artifactId>
</pluginExecutions> <versionRange>
</lifecycleMappingMetadata> [3.7.3,)
</configuration> </versionRange>
</plugin> <goals>
</plugins> <goal>generate</goal>
</pluginManagement> </goals>
</build> </pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<profiles> <profiles>
<profile> <profile>
@ -245,21 +245,21 @@
</build> </build>
</profile> </profile>
</profiles> </profiles>
<properties> <properties>
<org.jooq.version>3.8.6</org.jooq.version> <org.jooq.version>3.8.6</org.jooq.version>
<com.h2database.version>1.4.193</com.h2database.version> <com.h2database.version>1.4.193</com.h2database.version>
<org.springframework.version>4.3.4.RELEASE</org.springframework.version> <org.springframework.version>4.3.4.RELEASE</org.springframework.version>
<org.slf4j.version>1.7.21</org.slf4j.version> <org.slf4j.version>1.7.21</org.slf4j.version>
<ch.qos.logback.version>1.1.7</ch.qos.logback.version> <ch.qos.logback.version>1.1.7</ch.qos.logback.version>
<junit.version>4.12</junit.version> <junit.version>4.12</junit.version>
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version> <maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version> <maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
<lifecycle-mapping.version>1.0.0</lifecycle-mapping.version> <lifecycle-mapping.version>1.0.0</lifecycle-mapping.version>
<sql-maven-plugin.version>1.5</sql-maven-plugin.version> <sql-maven-plugin.version>1.5</sql-maven-plugin.version>
<properties-maven-plugin.version>1.0.0</properties-maven-plugin.version> <properties-maven-plugin.version>1.0.0</properties-maven-plugin.version>
</properties> </properties>
</project> </project>

View File

@ -8,7 +8,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version> <version>1.4.4.RELEASE</version>
</parent> </parent>
<dependencies> <dependencies>

View File

@ -13,7 +13,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version> <version>1.4.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository --> <relativePath/> <!-- lookup parent from repository -->
</parent> </parent>

View File

@ -12,7 +12,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version> <version>1.4.4.RELEASE</version>
<relativePath></relativePath> <relativePath></relativePath>
</parent> </parent>

View File

@ -0,0 +1,35 @@
package com.baeldung.model;
import org.springframework.web.multipart.MultipartFile;
public class FormDataWithFile {
private String name;
private String email;
private MultipartFile file;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public MultipartFile getFile() {
return file;
}
public void setFile(MultipartFile file) {
this.file = file;
}
}

View File

@ -2,11 +2,14 @@ package com.baeldung.web.controller;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import com.baeldung.model.FormDataWithFile;
@Controller @Controller
public class FileUploadController { public class FileUploadController {
@ -29,4 +32,21 @@ public class FileUploadController {
modelMap.addAttribute("files", files); modelMap.addAttribute("files", files);
return "fileUploadView"; return "fileUploadView";
} }
@RequestMapping(value = "/uploadFileWithAddtionalData", method = RequestMethod.POST)
public String submit(@RequestParam final MultipartFile file, @RequestParam final String name, @RequestParam final String email, final ModelMap modelMap) {
modelMap.addAttribute("name", name);
modelMap.addAttribute("email", email);
modelMap.addAttribute("file", file);
return "fileUploadView";
}
@RequestMapping(value = "/uploadFileModelAttribute", method = RequestMethod.POST)
public String submit(@ModelAttribute final FormDataWithFile formDataWithFile, final ModelMap modelMap) {
modelMap.addAttribute("formDataWithFile", formDataWithFile);
return "fileUploadView";
}
} }

View File

@ -49,6 +49,58 @@
</table> </table>
</form:form> </form:form>
<br />
<h3>Fill the Form and Select a File (<code>@RequestParam</code>)</h3>
<form:form method="POST" action="/spring-mvc-java/uploadFileWithAddtionalData" enctype="multipart/form-data">
<table>
<tr>
<td>Name</td>
<td><input type="text" name="name" /></td>
</tr>
<tr>
<td>Email</td>
<td><input type="text" name="email" /></td>
</tr>
<tr>
<td>Select a file to upload</td>
<td><input type="file" name="file" /></td>
</tr>
<tr>
<td><input type="submit" value="Submit" /></td>
</tr>
</table>
</form:form>
<br />
<h3>Fill the Form and Select a File (<code>@ModelAttribute</code>)</h3>
<form:form method="POST" action="/spring-mvc-java/uploadFileModelAttribute" enctype="multipart/form-data">
<table>
<tr>
<td>Name</td>
<td><input type="text" name="name" /></td>
</tr>
<tr>
<td>Email</td>
<td><input type="text" name="email" /></td>
</tr>
<tr>
<td>Select a file to upload</td>
<td><input type="file" name="file" /></td>
</tr>
<tr>
<td><input type="submit" value="Submit" /></td>
</tr>
</table>
</form:form>
</body> </body>

View File

@ -32,5 +32,48 @@
</tr> </tr>
</c:forEach> </c:forEach>
</table> </table>
<br />
<h2>Submitted File with Data (<code>@RequestParam</code>)</h2>
<table>
<tr>
<td>Name :</td>
<td>${name}</td>
</tr>
<tr>
<td>Email :</td>
<td>${email}</td>
</tr>
<tr>
<td>OriginalFileName :</td>
<td>${file.originalFilename}</td>
</tr>
<tr>
<td>Type :</td>
<td>${file.contentType}</td>
</tr>
</table>
<br />
<h2>Submitted File with Data (<code>@ModelAttribute</code>)</h2>
<table>
<tr>
<td>Name :</td>
<td>${formDataWithFile.name}</td>
</tr>
<tr>
<td>Email :</td>
<td>${formDataWithFile.email}</td>
</tr>
<tr>
<td>OriginalFileName :</td>
<td>${formDataWithFile.file.originalFilename}</td>
</tr>
<tr>
<td>Type :</td>
<td>${formDataWithFile.file.contentType}</td>
</tr>
</table>
</body> </body>
</html> </html>

View File

@ -10,7 +10,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version> <version>1.4.4.RELEASE</version>
</parent> </parent>
<dependencies> <dependencies>

View File

@ -9,7 +9,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version> <version>1.4.4.RELEASE</version>
</parent> </parent>
<properties> <properties>

View File

@ -13,7 +13,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version> <version>1.4.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository --> <relativePath/> <!-- lookup parent from repository -->
</parent> </parent>

View File

@ -11,7 +11,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version> <version>1.4.4.RELEASE</version>
</parent> </parent>
<dependencies> <dependencies>

View File

@ -14,7 +14,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version> <version>1.4.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository --> <relativePath/> <!-- lookup parent from repository -->
</parent> </parent>

View File

@ -13,7 +13,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version> <version>1.4.4.RELEASE</version>
</parent> </parent>
<dependencies> <dependencies>

View File

@ -13,7 +13,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version> <version>1.4.4.RELEASE</version>
</parent> </parent>
<dependencies> <dependencies>

View File

@ -13,7 +13,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version> <version>1.4.4.RELEASE</version>
</parent> </parent>
<dependencies> <dependencies>

View File

@ -13,7 +13,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version> <version>1.4.4.RELEASE</version>
</parent> </parent>
<dependencies> <dependencies>

View File

@ -13,7 +13,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version> <version>1.4.4.RELEASE</version>
</parent> </parent>
<dependencies> <dependencies>

View File

@ -13,7 +13,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version> <version>1.4.4.RELEASE</version>
</parent> </parent>
<dependencies> <dependencies>

View File

@ -13,7 +13,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version> <version>1.4.4.RELEASE</version>
</parent> </parent>
<dependencies> <dependencies>

View File

@ -11,7 +11,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version> <version>1.4.4.RELEASE</version>
<relativePath /> <relativePath />
</parent> </parent>

View File

@ -4,12 +4,12 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
<artifactId>spring-security-custom-permission</artifactId> <artifactId>spring-security-mvc-boot</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging> <packaging>war</packaging>
<name>spring-security-custom-permission</name> <name>spring-security-mvc-boot</name>
<description>Spring Security custom permission</description> <description>Spring Security MVC Boot</description>
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>

View File

@ -1,5 +1,5 @@
server.port=8082 server.port=8082
server.context-path=/spring-security-custom-permission server.context-path=/spring-security-mvc-boot
spring.datasource.driver-class-name=org.h2.Driver spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.url=jdbc:h2:mem:security_permission;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE spring.datasource.url=jdbc:h2:mem:security_permission;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
spring.datasource.username=sa spring.datasource.username=sa

View File

@ -14,24 +14,24 @@ import com.jayway.restassured.specification.RequestSpecification;
public class LiveTest { public class LiveTest {
private final FormAuthConfig formAuthConfig = new FormAuthConfig("http://localhost:8082/spring-security-custom-permission/login", "username", "password"); private final FormAuthConfig formAuthConfig = new FormAuthConfig("http://localhost:8082/spring-security-mvc-boot/login", "username", "password");
@Test @Test
public void givenUserWithReadPrivilegeAndHasPermission_whenGetFooById_thenOK() { public void givenUserWithReadPrivilegeAndHasPermission_whenGetFooById_thenOK() {
final Response response = givenAuth("john", "123").get("http://localhost:8082/spring-security-custom-permission/foos/1"); final Response response = givenAuth("john", "123").get("http://localhost:8082/spring-security-mvc-boot/foos/1");
assertEquals(200, response.getStatusCode()); assertEquals(200, response.getStatusCode());
assertTrue(response.asString().contains("id")); assertTrue(response.asString().contains("id"));
} }
@Test @Test
public void givenUserWithNoWritePrivilegeAndHasPermission_whenPostFoo_thenForbidden() { public void givenUserWithNoWritePrivilegeAndHasPermission_whenPostFoo_thenForbidden() {
final Response response = givenAuth("john", "123").contentType(MediaType.APPLICATION_JSON_VALUE).body(new Foo("sample")).post("http://localhost:8082/spring-security-custom-permission/foos"); final Response response = givenAuth("john", "123").contentType(MediaType.APPLICATION_JSON_VALUE).body(new Foo("sample")).post("http://localhost:8082/spring-security-mvc-boot/foos");
assertEquals(403, response.getStatusCode()); assertEquals(403, response.getStatusCode());
} }
@Test @Test
public void givenUserWithWritePrivilegeAndHasPermission_whenPostFoo_thenOk() { public void givenUserWithWritePrivilegeAndHasPermission_whenPostFoo_thenOk() {
final Response response = givenAuth("tom", "111").contentType(MediaType.APPLICATION_JSON_VALUE).body(new Foo("sample")).post("http://localhost:8082/spring-security-custom-permission/foos"); final Response response = givenAuth("tom", "111").contentType(MediaType.APPLICATION_JSON_VALUE).body(new Foo("sample")).post("http://localhost:8082/spring-security-mvc-boot/foos");
assertEquals(201, response.getStatusCode()); assertEquals(201, response.getStatusCode());
assertTrue(response.asString().contains("id")); assertTrue(response.asString().contains("id"));
} }
@ -40,14 +40,14 @@ public class LiveTest {
@Test @Test
public void givenUserMemberInOrganization_whenGetOrganization_thenOK() { public void givenUserMemberInOrganization_whenGetOrganization_thenOK() {
final Response response = givenAuth("john", "123").get("http://localhost:8082/spring-security-custom-permission/organizations/1"); final Response response = givenAuth("john", "123").get("http://localhost:8082/spring-security-mvc-boot/organizations/1");
assertEquals(200, response.getStatusCode()); assertEquals(200, response.getStatusCode());
assertTrue(response.asString().contains("id")); assertTrue(response.asString().contains("id"));
} }
@Test @Test
public void givenUserMemberNotInOrganization_whenGetOrganization_thenForbidden() { public void givenUserMemberNotInOrganization_whenGetOrganization_thenForbidden() {
final Response response = givenAuth("john", "123").get("http://localhost:8082/spring-security-custom-permission/organizations/2"); final Response response = givenAuth("john", "123").get("http://localhost:8082/spring-security-mvc-boot/organizations/2");
assertEquals(403, response.getStatusCode()); assertEquals(403, response.getStatusCode());
} }
@ -55,7 +55,7 @@ public class LiveTest {
@Test @Test
public void givenDisabledSecurityExpression_whenGetFooByName_thenError() { public void givenDisabledSecurityExpression_whenGetFooByName_thenError() {
final Response response = givenAuth("john", "123").get("http://localhost:8082/spring-security-custom-permission/foos?name=sample"); final Response response = givenAuth("john", "123").get("http://localhost:8082/spring-security-mvc-boot/foos?name=sample");
assertEquals(500, response.getStatusCode()); assertEquals(500, response.getStatusCode());
assertTrue(response.asString().contains("method hasAuthority() not allowed")); assertTrue(response.asString().contains("method hasAuthority() not allowed"));
} }

View File

@ -10,7 +10,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version> <version>1.4.4.RELEASE</version>
</parent> </parent>
<dependencies> <dependencies>

View File

@ -13,7 +13,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version> <version>1.4.4.RELEASE</version>
</parent> </parent>
<dependencies> <dependencies>

View File

@ -10,7 +10,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version> <version>1.4.4.RELEASE</version>
</parent> </parent>
<dependencies> <dependencies>

View File

@ -10,7 +10,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version> <version>1.4.4.RELEASE</version>
</parent> </parent>
<dependencies> <dependencies>

View File

@ -16,7 +16,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version> <version>1.4.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository --> <relativePath/> <!-- lookup parent from repository -->
</parent> </parent>

View File

@ -11,7 +11,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version> <version>1.4.4.RELEASE</version>
<relativePath/> <relativePath/>
<!-- lookup parent from repository --> <!-- lookup parent from repository -->
</parent> </parent>

View File

@ -9,7 +9,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version> <version>1.4.4.RELEASE</version>
<relativePath></relativePath> <relativePath></relativePath>
</parent> </parent>

View File

@ -10,7 +10,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version> <version>1.4.4.RELEASE</version>
</parent> </parent>
<modules> <modules>