Add Send Array as Part of x-www-form-urlencoded (#12808)
* Add Send Array as Part of x-www-form-urlencoded * Add README.md
This commit is contained in:
parent
d39aa6b1c6
commit
36fef5ec7a
@ -34,6 +34,7 @@
|
||||
<module>spring-rest-angular</module>
|
||||
<module>spring-rest-http</module>
|
||||
<module>spring-rest-http-2</module>
|
||||
<module>spring-rest-http-3</module>
|
||||
<module>spring-rest-query-language</module>
|
||||
<module>spring-rest-shell</module>
|
||||
<module>spring-rest-simple</module>
|
||||
|
@ -14,4 +14,4 @@ The "REST With Spring 2" Classes: http://bit.ly/restwithspring
|
||||
- [Get All Endpoints in Spring Boot](https://www.baeldung.com/spring-boot-get-all-endpoints)
|
||||
- [HTTP PUT vs. POST in REST API](https://www.baeldung.com/rest-http-put-vs-post)
|
||||
- [415 Unsupported MediaType in Spring Application](https://www.baeldung.com/spring-415-unsupported-mediatype)
|
||||
- More articles: [[<-- prev]](../spring-rest-http)
|
||||
- More articles: [[next -->]](../spring-rest-http-3)
|
||||
|
10
spring-web-modules/spring-rest-http-3/README.md
Normal file
10
spring-web-modules/spring-rest-http-3/README.md
Normal file
@ -0,0 +1,10 @@
|
||||
## Spring REST HTTP 3
|
||||
|
||||
This module contains articles about HTTP in REST APIs with Spring.
|
||||
|
||||
### The Course
|
||||
The "REST With Spring 3" Classes: http://bit.ly/restwithspring
|
||||
|
||||
### Relevant Articles:
|
||||
|
||||
- More articles: [[<-- prev]](../spring-rest-http)
|
25
spring-web-modules/spring-rest-http-3/pom.xml
Normal file
25
spring-web-modules/spring-rest-http-3/pom.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?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>
|
||||
<artifactId>spring-rest-http-3</artifactId>
|
||||
<version>0.1-SNAPSHOT</version>
|
||||
<name>spring-rest-http-3</name>
|
||||
<packaging>war</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-boot-2</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-boot-2</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -0,0 +1,12 @@
|
||||
package com.baeldung;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class SpringBootRest3Application {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SpringBootRest3Application.class, args);
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.baeldung.xwwwformurlencoded;
|
||||
|
||||
class Course {
|
||||
|
||||
private String name;
|
||||
private int hours;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getHours() {
|
||||
return hours;
|
||||
}
|
||||
|
||||
public void setHours(int hours) {
|
||||
this.hours = hours;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package com.baeldung.xwwwformurlencoded;
|
||||
|
||||
class StudentComplex {
|
||||
|
||||
private String firstName;
|
||||
private String lastName;
|
||||
private Course[] courses;
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
public Course[] getCourses() {
|
||||
return courses;
|
||||
}
|
||||
|
||||
public void setCourses(Course[] courses) {
|
||||
this.courses = courses;
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.baeldung.xwwwformurlencoded;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/students")
|
||||
public class StudentController {
|
||||
|
||||
@PostMapping(path = "/simple",
|
||||
consumes = { MediaType.APPLICATION_FORM_URLENCODED_VALUE })
|
||||
public ResponseEntity<StudentSimple> createStudentSimple(StudentSimple student) {
|
||||
return ResponseEntity.ok(student);
|
||||
}
|
||||
|
||||
@PostMapping(path = "/complex",
|
||||
consumes = { MediaType.APPLICATION_FORM_URLENCODED_VALUE })
|
||||
public ResponseEntity<StudentComplex> createStudentComplex(StudentComplex student) {
|
||||
return ResponseEntity.ok(student);
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package com.baeldung.xwwwformurlencoded;
|
||||
|
||||
class StudentSimple {
|
||||
|
||||
private String firstName;
|
||||
private String lastName;
|
||||
private String[] courses;
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
public String[] getCourses() {
|
||||
return courses;
|
||||
}
|
||||
|
||||
public void setCourses(String[] courses) {
|
||||
this.courses = courses;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user