Why can @requestparam get file upload data in SpringMVC?Multipart File upload Spring BootSpring MVC MultipartFile problemsPosting JSON to Controller returns 400 Bad RequestSpring rest: Consuming x-www-form-urlencoded associative arrayUnable to upload file from Angular client to Spring Java server: Says 400 errorAngular 4 multipart form with null parametersSpring File Upload with RequestParamfrom andriod i am trying to upload image and i am using web services in javaIn SpringMVC, why is my @RequestParam disappearing?Issue with MultipartFile Upload From React/Node

Intersecting with the x-axis / intersecting the x-axis

Why is PerfectForwardSecrecy considered OK, when it has same defects as salt-less password hashing?

Extending Kan fibrations, without using minimal fibrations

Has there been evidence of any other gods?

How is CoreiX like Corei5, i7 is related to Haswell, Ivy Bridge?

Why should password hash verification be time constant?

My perfect evil overlord plan... or is it?

Improving Sati-Sampajañña (situative wisdom)

Further factorisation of a difference of cubes?

Remove color cast in darktable?

When quoting someone, is it proper to change "gotta" to "got to" without modifying the rest of the quote?

Is there an application which does HTTP PUT?

Why are low spin tetrahedral complexes so rare?

Why was wildfire not used during the Battle of Winterfell?

Was the Highlands Ranch shooting the 115th mass shooting in the US in 2019

Removing all characters except digits from clipboard

Why are parallelograms defined as quadrilaterals? What term would encompass polygons with greater than two parallel pairs?

Examples where existence is harder than evaluation

What does formal training in a field mean?

Is it nonsense to say B -> [A -> B]?

How to handle DM constantly stealing everything from sleeping characters?

Would encrypting a database protect against a compromised admin account?

Detect the first rising edge of 3 input signals

Can the president of the United States be guilty of insider trading?



Why can @requestparam get file upload data in SpringMVC?


Multipart File upload Spring BootSpring MVC MultipartFile problemsPosting JSON to Controller returns 400 Bad RequestSpring rest: Consuming x-www-form-urlencoded associative arrayUnable to upload file from Angular client to Spring Java server: Says 400 errorAngular 4 multipart form with null parametersSpring File Upload with RequestParamfrom andriod i am trying to upload image and i am using web services in javaIn SpringMVC, why is my @RequestParam disappearing?Issue with MultipartFile Upload From React/Node






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















@requestparam functions like request.getquerystring (). Why does she receive a multipart/form-data type contentType when @requestbody cannot?Please tell me why?



 @PostMapping(value = "/uploadFileByUserTrainId", consumes = "multipart/form-data")
@Student(Student.Authority.A, Student.Authority.B, Student.Authority.C)
public WebMessage uploadFileByUserTrainId(
@RequestParam(value = "document", required = false) MultipartFile multipartFile,
@RequestParam(value = "documetnRe", required = false) MultipartFile multipartFileRe,
@RequestParam("id") long id,
@RequestParam(value = "documentFileType", required = false) String fileType,
@RequestParam(value = "documentFileReType", required = false) String fileReType,
HttpServletRequest httpServletRequest)
// todo










share|improve this question






















  • Requestbody means request parameters in json format. Files can not be uploaded in json format.

    – hamed
    Mar 23 at 10:05











  • So why does @requestparam receive files?

    – CoolerWu
    Mar 23 at 10:11











  • requestparam is not in json format and can contains any format including multipart/form-data.

    – hamed
    Mar 23 at 10:16











  • You mean @requestparam can get it as long as it is not in json format?

    – CoolerWu
    Mar 23 at 10:30











  • Yes. @requestparam is exactly for get params in formats other than json.

    – hamed
    Mar 23 at 11:15


















0















@requestparam functions like request.getquerystring (). Why does she receive a multipart/form-data type contentType when @requestbody cannot?Please tell me why?



 @PostMapping(value = "/uploadFileByUserTrainId", consumes = "multipart/form-data")
@Student(Student.Authority.A, Student.Authority.B, Student.Authority.C)
public WebMessage uploadFileByUserTrainId(
@RequestParam(value = "document", required = false) MultipartFile multipartFile,
@RequestParam(value = "documetnRe", required = false) MultipartFile multipartFileRe,
@RequestParam("id") long id,
@RequestParam(value = "documentFileType", required = false) String fileType,
@RequestParam(value = "documentFileReType", required = false) String fileReType,
HttpServletRequest httpServletRequest)
// todo










share|improve this question






















  • Requestbody means request parameters in json format. Files can not be uploaded in json format.

    – hamed
    Mar 23 at 10:05











  • So why does @requestparam receive files?

    – CoolerWu
    Mar 23 at 10:11











  • requestparam is not in json format and can contains any format including multipart/form-data.

    – hamed
    Mar 23 at 10:16











  • You mean @requestparam can get it as long as it is not in json format?

    – CoolerWu
    Mar 23 at 10:30











  • Yes. @requestparam is exactly for get params in formats other than json.

    – hamed
    Mar 23 at 11:15














0












0








0








@requestparam functions like request.getquerystring (). Why does she receive a multipart/form-data type contentType when @requestbody cannot?Please tell me why?



 @PostMapping(value = "/uploadFileByUserTrainId", consumes = "multipart/form-data")
@Student(Student.Authority.A, Student.Authority.B, Student.Authority.C)
public WebMessage uploadFileByUserTrainId(
@RequestParam(value = "document", required = false) MultipartFile multipartFile,
@RequestParam(value = "documetnRe", required = false) MultipartFile multipartFileRe,
@RequestParam("id") long id,
@RequestParam(value = "documentFileType", required = false) String fileType,
@RequestParam(value = "documentFileReType", required = false) String fileReType,
HttpServletRequest httpServletRequest)
// todo










share|improve this question














@requestparam functions like request.getquerystring (). Why does she receive a multipart/form-data type contentType when @requestbody cannot?Please tell me why?



 @PostMapping(value = "/uploadFileByUserTrainId", consumes = "multipart/form-data")
@Student(Student.Authority.A, Student.Authority.B, Student.Authority.C)
public WebMessage uploadFileByUserTrainId(
@RequestParam(value = "document", required = false) MultipartFile multipartFile,
@RequestParam(value = "documetnRe", required = false) MultipartFile multipartFileRe,
@RequestParam("id") long id,
@RequestParam(value = "documentFileType", required = false) String fileType,
@RequestParam(value = "documentFileReType", required = false) String fileReType,
HttpServletRequest httpServletRequest)
// todo







spring spring-boot spring-mvc






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 23 at 10:01









CoolerWuCoolerWu

11




11












  • Requestbody means request parameters in json format. Files can not be uploaded in json format.

    – hamed
    Mar 23 at 10:05











  • So why does @requestparam receive files?

    – CoolerWu
    Mar 23 at 10:11











  • requestparam is not in json format and can contains any format including multipart/form-data.

    – hamed
    Mar 23 at 10:16











  • You mean @requestparam can get it as long as it is not in json format?

    – CoolerWu
    Mar 23 at 10:30











  • Yes. @requestparam is exactly for get params in formats other than json.

    – hamed
    Mar 23 at 11:15


















  • Requestbody means request parameters in json format. Files can not be uploaded in json format.

    – hamed
    Mar 23 at 10:05











  • So why does @requestparam receive files?

    – CoolerWu
    Mar 23 at 10:11











  • requestparam is not in json format and can contains any format including multipart/form-data.

    – hamed
    Mar 23 at 10:16











  • You mean @requestparam can get it as long as it is not in json format?

    – CoolerWu
    Mar 23 at 10:30











  • Yes. @requestparam is exactly for get params in formats other than json.

    – hamed
    Mar 23 at 11:15

















Requestbody means request parameters in json format. Files can not be uploaded in json format.

– hamed
Mar 23 at 10:05





Requestbody means request parameters in json format. Files can not be uploaded in json format.

– hamed
Mar 23 at 10:05













So why does @requestparam receive files?

– CoolerWu
Mar 23 at 10:11





So why does @requestparam receive files?

– CoolerWu
Mar 23 at 10:11













requestparam is not in json format and can contains any format including multipart/form-data.

– hamed
Mar 23 at 10:16





requestparam is not in json format and can contains any format including multipart/form-data.

– hamed
Mar 23 at 10:16













You mean @requestparam can get it as long as it is not in json format?

– CoolerWu
Mar 23 at 10:30





You mean @requestparam can get it as long as it is not in json format?

– CoolerWu
Mar 23 at 10:30













Yes. @requestparam is exactly for get params in formats other than json.

– hamed
Mar 23 at 11:15






Yes. @requestparam is exactly for get params in formats other than json.

– hamed
Mar 23 at 11:15













1 Answer
1






active

oldest

votes


















0














It is nothing wrong using @RequestParam with Multipart file.



@RequestParam annotation can also be used to associate the part of a "multipart/form-data" request with a method argument supporting the same method argument types. The main difference is that when the method argument is not a String, @RequestParam relies on type conversion via a registered Converter or PropertyEditor






share|improve this answer























  • The main difference is that when the method argument is not a String, @RequestParam relies on type conversion via a registered Converter or PropertyEditor. I don't quite understand this sentence.

    – CoolerWu
    Apr 5 at 15:28












  • Here you are looking for Type Conversion As per spring documentation String-based values extracted from the request including request parameters, path variables, request headers, and cookie values may need to be converted to the target type of the method parameter or field (e.g., binding a request parameter to a field in an @ModelAttribute parameter) they’re bound to. If the target type is not String, Spring automatically converts to the appropriate type. All simple types such as int, long, Date, etc. are supported.

    – Tech at The Sparks Foundation
    Apr 5 at 17:38












  • In Spring MVC, "request parameters" map to query parameters, form data, and parts in multipart requests. The official document said so, I understand some, thank you.

    – CoolerWu
    Apr 8 at 13:02











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55312578%2fwhy-can-requestparam-get-file-upload-data-in-springmvc%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














It is nothing wrong using @RequestParam with Multipart file.



@RequestParam annotation can also be used to associate the part of a "multipart/form-data" request with a method argument supporting the same method argument types. The main difference is that when the method argument is not a String, @RequestParam relies on type conversion via a registered Converter or PropertyEditor






share|improve this answer























  • The main difference is that when the method argument is not a String, @RequestParam relies on type conversion via a registered Converter or PropertyEditor. I don't quite understand this sentence.

    – CoolerWu
    Apr 5 at 15:28












  • Here you are looking for Type Conversion As per spring documentation String-based values extracted from the request including request parameters, path variables, request headers, and cookie values may need to be converted to the target type of the method parameter or field (e.g., binding a request parameter to a field in an @ModelAttribute parameter) they’re bound to. If the target type is not String, Spring automatically converts to the appropriate type. All simple types such as int, long, Date, etc. are supported.

    – Tech at The Sparks Foundation
    Apr 5 at 17:38












  • In Spring MVC, "request parameters" map to query parameters, form data, and parts in multipart requests. The official document said so, I understand some, thank you.

    – CoolerWu
    Apr 8 at 13:02















0














It is nothing wrong using @RequestParam with Multipart file.



@RequestParam annotation can also be used to associate the part of a "multipart/form-data" request with a method argument supporting the same method argument types. The main difference is that when the method argument is not a String, @RequestParam relies on type conversion via a registered Converter or PropertyEditor






share|improve this answer























  • The main difference is that when the method argument is not a String, @RequestParam relies on type conversion via a registered Converter or PropertyEditor. I don't quite understand this sentence.

    – CoolerWu
    Apr 5 at 15:28












  • Here you are looking for Type Conversion As per spring documentation String-based values extracted from the request including request parameters, path variables, request headers, and cookie values may need to be converted to the target type of the method parameter or field (e.g., binding a request parameter to a field in an @ModelAttribute parameter) they’re bound to. If the target type is not String, Spring automatically converts to the appropriate type. All simple types such as int, long, Date, etc. are supported.

    – Tech at The Sparks Foundation
    Apr 5 at 17:38












  • In Spring MVC, "request parameters" map to query parameters, form data, and parts in multipart requests. The official document said so, I understand some, thank you.

    – CoolerWu
    Apr 8 at 13:02













0












0








0







It is nothing wrong using @RequestParam with Multipart file.



@RequestParam annotation can also be used to associate the part of a "multipart/form-data" request with a method argument supporting the same method argument types. The main difference is that when the method argument is not a String, @RequestParam relies on type conversion via a registered Converter or PropertyEditor






share|improve this answer













It is nothing wrong using @RequestParam with Multipart file.



@RequestParam annotation can also be used to associate the part of a "multipart/form-data" request with a method argument supporting the same method argument types. The main difference is that when the method argument is not a String, @RequestParam relies on type conversion via a registered Converter or PropertyEditor







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 24 at 13:39









Tech at The Sparks FoundationTech at The Sparks Foundation

1112




1112












  • The main difference is that when the method argument is not a String, @RequestParam relies on type conversion via a registered Converter or PropertyEditor. I don't quite understand this sentence.

    – CoolerWu
    Apr 5 at 15:28












  • Here you are looking for Type Conversion As per spring documentation String-based values extracted from the request including request parameters, path variables, request headers, and cookie values may need to be converted to the target type of the method parameter or field (e.g., binding a request parameter to a field in an @ModelAttribute parameter) they’re bound to. If the target type is not String, Spring automatically converts to the appropriate type. All simple types such as int, long, Date, etc. are supported.

    – Tech at The Sparks Foundation
    Apr 5 at 17:38












  • In Spring MVC, "request parameters" map to query parameters, form data, and parts in multipart requests. The official document said so, I understand some, thank you.

    – CoolerWu
    Apr 8 at 13:02

















  • The main difference is that when the method argument is not a String, @RequestParam relies on type conversion via a registered Converter or PropertyEditor. I don't quite understand this sentence.

    – CoolerWu
    Apr 5 at 15:28












  • Here you are looking for Type Conversion As per spring documentation String-based values extracted from the request including request parameters, path variables, request headers, and cookie values may need to be converted to the target type of the method parameter or field (e.g., binding a request parameter to a field in an @ModelAttribute parameter) they’re bound to. If the target type is not String, Spring automatically converts to the appropriate type. All simple types such as int, long, Date, etc. are supported.

    – Tech at The Sparks Foundation
    Apr 5 at 17:38












  • In Spring MVC, "request parameters" map to query parameters, form data, and parts in multipart requests. The official document said so, I understand some, thank you.

    – CoolerWu
    Apr 8 at 13:02
















The main difference is that when the method argument is not a String, @RequestParam relies on type conversion via a registered Converter or PropertyEditor. I don't quite understand this sentence.

– CoolerWu
Apr 5 at 15:28






The main difference is that when the method argument is not a String, @RequestParam relies on type conversion via a registered Converter or PropertyEditor. I don't quite understand this sentence.

– CoolerWu
Apr 5 at 15:28














Here you are looking for Type Conversion As per spring documentation String-based values extracted from the request including request parameters, path variables, request headers, and cookie values may need to be converted to the target type of the method parameter or field (e.g., binding a request parameter to a field in an @ModelAttribute parameter) they’re bound to. If the target type is not String, Spring automatically converts to the appropriate type. All simple types such as int, long, Date, etc. are supported.

– Tech at The Sparks Foundation
Apr 5 at 17:38






Here you are looking for Type Conversion As per spring documentation String-based values extracted from the request including request parameters, path variables, request headers, and cookie values may need to be converted to the target type of the method parameter or field (e.g., binding a request parameter to a field in an @ModelAttribute parameter) they’re bound to. If the target type is not String, Spring automatically converts to the appropriate type. All simple types such as int, long, Date, etc. are supported.

– Tech at The Sparks Foundation
Apr 5 at 17:38














In Spring MVC, "request parameters" map to query parameters, form data, and parts in multipart requests. The official document said so, I understand some, thank you.

– CoolerWu
Apr 8 at 13:02





In Spring MVC, "request parameters" map to query parameters, form data, and parts in multipart requests. The official document said so, I understand some, thank you.

– CoolerWu
Apr 8 at 13:02



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55312578%2fwhy-can-requestparam-get-file-upload-data-in-springmvc%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현