feat(修改 RequestPart 问题): 修改 RequestPart 问题
This commit is contained in:
parent
deed1bb13a
commit
3738110395
|
@ -305,4 +305,64 @@ public class CommonController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/testPart")
|
||||||
|
public void testPart(@RequestPart(value = "file", required = false) MultipartFile file,
|
||||||
|
@RequestPart(value = "str1", required = false) String str1,
|
||||||
|
@RequestPart(value = "f1", required = false) String f1) {
|
||||||
|
|
||||||
|
String s = null;
|
||||||
|
if (file != null) {
|
||||||
|
s = minioUtil.uploadFile("temp", file);
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("s = " + s);
|
||||||
|
|
||||||
|
System.out.println("str1 = " + str1);
|
||||||
|
|
||||||
|
System.out.println("f1 = " + f1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/testPartOfFloat")
|
||||||
|
public void testPartOfFloat(@RequestPart(value = "file", required = false) MultipartFile file,
|
||||||
|
@RequestPart(value = "str1", required = false) String str1,
|
||||||
|
@RequestPart(value = "f1", required = false) Float f1) {
|
||||||
|
|
||||||
|
String s = null;
|
||||||
|
if (file != null) {
|
||||||
|
s = minioUtil.uploadFile("temp", file);
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("s = " + s);
|
||||||
|
|
||||||
|
System.out.println("str1 = " + str1);
|
||||||
|
|
||||||
|
System.out.println("f1 = " + f1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/testParam")
|
||||||
|
public void testParm(@RequestPart(value = "file", required = false) MultipartFile file,
|
||||||
|
@RequestParam(value = "str1", required = true) String str1,
|
||||||
|
@RequestParam(value = "f1", required = false) Float f1) {
|
||||||
|
|
||||||
|
String s = null;
|
||||||
|
if (file != null) {
|
||||||
|
s = minioUtil.uploadFile("temp", file);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println("s = " + s);
|
||||||
|
|
||||||
|
System.out.println("str1 = " + str1);
|
||||||
|
|
||||||
|
System.out.println("f1 = " + f1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
/*
|
||||||
|
package com.guwan.backend.converter;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class MultipartJackson2HttpMessageConverter extends AbstractJackson2HttpMessageConverter {
|
||||||
|
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* converter for support http request with header content-type: multipart/form-data
|
||||||
|
*//*
|
||||||
|
|
||||||
|
public MultipartJackson2HttpMessageConverter(ObjectMapper objectMapper) {
|
||||||
|
super(objectMapper, MediaType.APPLICATION_OCTET_STREAM);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canWrite(Class<?> clazz, MediaType mediaType) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canWrite(Type type, Class<?> clazz, MediaType mediaType) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean canWrite(MediaType mediaType) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}*/
|
Loading…
Reference in New Issue