Skip to content

Latest commit

 

History

History

spring

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Setup

  • Install dependency
implementation 'com.github.joutvhu:spring-form-json:1.30.0'
<dependency>
    <groupId>com.github.joutvhu</groupId>
    <artifactId>spring-form-json</artifactId>
    <version>1.30.0</version>
</dependency>
  • Version compatibility matrix
Spring Form JSON Version Spring Boot Version
1.25.0 2.5.x - 2.7.x
1.30.0 >= 3.0.0
  • Add FormJsonMethodArgumentResolver to resolvers.
@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Override
    public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
        resolvers.add(new FormJsonMethodArgumentResolver());
    }
}

Using

  • Use data type org.springframework.web.multipart.MultipartFile to define files in the model.

  • Using annotation @FormJson before the parameter.

@PostMapping
public ResponseEntity<PropertyResult> createProperty(@FormJson PropertyRequest data)
{
    ...
}