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?
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?
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.
recently I want to try a relatively simple development method. only writes sql statements in the xml file, and both incoming and outgoing parameters are map. Do something else in controller and service. then write a test code. this is the param, of...
< H2 > spring boot2 RestTemplate request URL timed out < H2 > RestTemplate configuration code is as follows @Bean public RestTemplate restTemplate(RestTemplateBuilder builder) { HttpComponentsClientHttpRequestFactory httpRequestFactor...