java - How does Spring MVC convert @RequestParam values? -


i'm new spring framework, , symptom, want keep adoption of web mvc portions simple possible, i'm using annotation functions work spring. in past, i've used:
int value = integer.valueof(request.getparameter("numbervalue"))
to pull values parameters - explicitly converting string returned getparameter().
helpfully, i've noticed when use spring's terminology:
@requestparameter("numbervalue") int numval
conversion handled automatically. nice, "black box" me. tried looking @ questions on here or in spring documentation, information deals custom conversions (like converter) objects or formatting issues. want know how spring handles primitive type conversions @requestparam default.

i've noticed when use spring's terminology: @requestparameter("numbervalue") int numval conversion handled automatically.

here looking type conversion

as per spring documentation given on link

string-based values extracted request including request parameters, path variables, request headers, , cookie values may need converted target type of method parameter or field (e.g., binding request parameter field in @modelattribute parameter) they’re bound to. if target type not string, spring automatically converts appropriate type. simple types such int, long, date, etc. supported.


Comments

Popular posts from this blog

SQL php on different pages to Insert (mysqli) -

How to combine associative arrays in bash? -

c++ - No viable overloaded operator for references a map -