getParameter
public java.lang.String getParameter(java.lang.String name)
Returns the value of a request parameter as a String
, or null
if the parameter does not exist. Request parameters are extra information sent with the request. For HTTP servlets, parameters are contained in the query string or posted form data.
将请求参数(a request parameter)的值作为 String 返回,如果参数不存在,则返回 null。
请求参数是随请求一起发送的额外信息。对于 HTTP servlet,参数包含在查询字符串或发布的表单数据中。
You should only use this method when you are sure the parameter has only one value. If the parameter might have more than one value, use getParameterValues(java.lang.String).
仅当确定参数只有一个值时,才应使用此方法。如果参数可能有多个值,请使用 getParameterValues(java.lang.String)。
用于读取提交的表单中的值
只能传name,不能传id
html里可以有重名name
If you use this method with a multivalued parameter, the value returned is equal to the first value in the array returned by getParameterValues
.
如果将此方法用于多值参数,则返回的值等于 getParameterValues 返回的数组中的第一个值。
If the parameter data was sent in the request body, such as occurs with an HTTP POST request, then reading the body directly via getInputStream() or getReader() can interfere with the execution of this method.
如果参数数据是在请求体中发送的,例如在HTTP POST请求中,那么直接通过getInputStream()或getReader()读取请求体可能会干扰此方法的执行。
Parameters:
name
- a String
specifying the name of the parameter
Returns:
a String
representing the single value of the parameter
See Also: