ChatGPT: Understanding HTTP request data formats: JSON, x-www-form-urlencoded and form-data

ChatGPT: Understanding HTTP request data formats: JSON, x-www-form-urlencoded and form-data Use postman to send a post request, add form-data data in the body, name=xxx, age=23, why do you get this result when outputting request.body() —————————-817240066476907930266144 Content-Disposition: form-data; name=”name” xxx —————————-817240066476907930266144 Content-Disposition: form-data; name=”age” 24 —————————-817240066476907930266144 ChatGPT: This is because when you send a POST request, […]

Gateway solves the problem of repeated acquisition of body streams, encrypts, decrypts, adds and deletes parameters for application/json, multipart/form-data, x-www-form-urlencoded.

1. CacheRequestFilter global filter solves the problem of repeated acquisition of body stream import org.springframework.cloud.gateway.filter.GatewayFilterChain; import org.springframework.cloud.gateway.filter.GlobalFilter; import org.springframework.core.Ordered; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferUtils; import org.springframework.core.io.buffer.DefaultDataBuffer; import org.springframework.core.io.buffer.DefaultDataBufferFactory; import org.springframework.http.HttpMethod; import org.springframework.http.server.reactive.ServerHttpRequest; import org.springframework.http.server.reactive.ServerHttpRequestDecorator; import org.springframework.stereotype.Component; import org.springframework.web.server.ServerWebExchange; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @Component public class CacheRequestFilter implements GlobalFilter, Ordered { @Override public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain […]

Notes on the use of encryption and decryption codes such as Md5/Base64/Aes+Base64/UrlEncode+UrlDecode in Oracle

Article directory Memo for implementing Md5/Base64/Aes + Base64/UrlEncode + UrlDecode and other encryption and decryption codes in Oracle 1. Implement Md5 2. Implement Base64 encryption/decryption 3. Implement UrlEncode and UrlDecode 4. Realize Aes + Base64: encryption/decryption [Aes Key is 16 bits] 4-1 sys authorization, create Aes + Base64 encryption, Aes + Base64 decryption method 4-2 […]

java restful application/x-www-form-urlencoded passing parameters

Scenario: When sending a text message, use the x-www-form-urlencoded encoding format to pass parameters. Specific requirements: parameter name illustrate Remark userId username timespan timestamp The format is yyyyMMddHHmmss password password Use original password + timestamp here Do MD5 encryption, 32-bit uppercase format phone Phone number Multiple separated by commas msgType encoding type Optional, if not […]

The front end uses application/x-www-form-urlencoded Spring List to receive parameters and throws an Invalid list index in property path exception

@Data public class TestDTO { private List<String> iccids; } Exception information: org.springframework.beans.InvalidPropertyException: Invalid property ‘iccids[1000]’ of bean class [com.simboss.avatar.aquaman.api.dto.TestDTO]: Invalid list index in property path ‘iccids[ 1000]’; nested exception is java.lang.IndexOutOfBoundsException: Index: 1000, Size: 1 at org.springframework.beans.AbstractNestablePropertyAccessor.processKeyedProperty(AbstractNestablePropertyAccessor.java:349) ~[spring-beans-5.2.12.RELEASE.jar:5.2.12.RELEASE] at org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:275) ~[spring-beans-5.2.12.RELEASE.jar:5.2.12.RELEASE] at org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:266) ~[spring-beans-5.2.12.RELEASE.jar:5.2.12.RELEASE] at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:104) ~[spring-beans-5.2.12.RELEASE.jar:5.2.12.RELEASE] at org.springframework.validation.DataBinder.applyPropertyValues(DataBinder.java:848) ~[spring-context-5.2.12.RELEASE.jar:5.2.12.RELEASE] at org.springframework.validation.DataBinder.doBind(DataBinder.java:744) ~[spring-context-5.2.12.RELEASE.jar:5.2.12.RELEASE] at org.springframework.web.bind.WebDataBinder.doBind(WebDataBinder.java:197) […]

The difference and extension of form-data and x-www-form-urlencoded

1. Foreword form-data and x-www-form-urlencoded, their complete representation is multipart/form-data and application/x-www-form-urlencoded. For convenience, we will use form-data and x-www-form-urlencoded below. The difference between the two can be described as a cliché, and there is a lot of information on Baidu. But I still want to use an article to summarize, mainly for two reasons: […]

[Solved] spring-boot uses a custom HttpMessageConverter to convert application/x-www-form-urlencoded request data into objects

1. Define the converter public class CustomerMessageConverter extends AbstractHttpMessageConverter<T> {<!– –> private static final FormHttpMessageConverter formHttpMessageConverter=new FormHttpMessageConverter(); private static final ObjectMapper mapper=new ObjectMapper(); @Override protected boolean supports(Class<?> aClass) {<!– –> return T.class==aClass; } @Override protected T readInternal(Class<? extends T> aClass, HttpInputMessage httpInputMessage) throws IOException, HttpMessageNotReadableException {<!– –> Map<String,String> map=formHttpMessageConverter.read(null,httpInputMessage).toSingleValueMap(); return mapper.convertValue(map,T.class); } @Override protected void […]

[Solved] [Java] Solve POST form submission error Content type ‘application/x-www-form-urlencoded; charset=UTF-8’ not supported

1. Error reporting scene The front-end POST form is submitted, and the background service reports an error Content type ‘application/x-www-form-urlencoded;charset=UTF-8’ not supported 2. Workaround application/x-www-form-urlencoded;charset=UTF-8 is in the form of key-value pair splicing, such as name=abc & amp;phone=123456, not the json format like application/json{“name” :”abc”,”phone”:”123456″} So make the following changes: Change the original receiving form […]