Spring Form Input From HttpServletRequest
From those who do not like what Spring automatically bind the form input to an object, we can do it ourselves by using HttpServletRequest
.
- In your controller,
import javax.servlet.http.HttpServletRequest
- In your method add HttpServletRequest as a parameter, Spring will give the value to you.
- Now you can use request.getParameter(…) to get field value or request.getParameterValues(…) to get array value. Note all value are in type
String
. You need to do your own conversion if needed.