Spring Controller receive parameter form

receive parameters from the front end (APP or other separate front end) in SpringMVC, usually in the form (valued by request.getParameters (xxx)) or directly from the Json object?
which is more convenient?

Jul.09,2021

for convenience, that must be json. Otherwise, how many fields do you need to write? how many get


look at the answer above, you still need to edit it.
first of all, if you can get the parameters using request.getParameters , it means that the json, is not sent from the client because json cannot get it with request.getParameter . Secondly, it does no harm to connect parameters directly with objects (unless there are only one or two parameters, but even if there are few parameters, you can directly use @ RequestParam without manually removing them from request)
if you still insist on request.getParameter with SpringMVC,. Or very familiar with these things, it is better to know everything directly getParameters; Or it is not familiar enough to know that the framework has a convenient function to obtain parameters


@ ModelAttribute take request.param, @ RequestBody take request.content.
both can be followed by an object. @ ModelAttribute can also take values from other places (such as redis) through custom methods, along with binding=false to avoid taking values from parameters.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e46afe-44be0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e46afe-44be0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?