1.必须初始化 2.那是你的String[]的地址,应该是str_test[0],str_test[1] 3.request.getParameterValues() Returns an array of String objects containing all of the values the given request parameter has, or null if the parameter does not exist. 返回request中所有参数的值,是一个String[],比如你这应该是"0"和"1",如果没设定就是nullgetParameterNames() Returns an Enumeration of String objects containing the names of the parameters contained in this request 返回request中所有的参数名,是Enumeration,你这是"param1"和"param2"两个StringsetAttribute(java.lang.String name,java.lang.Object o) Stores an attribute in this request. 在request中存储一个属性,设定它的name,o是存储的对象request.getAttribute("name"); Returns the value of the named attribute as an Object, or null if no attribute of the given name exists 取得名字为name的属性的值,如果不存在,返回nullrequest是一个在客户端和servlet传递信息的对象4.下载servlet.jar的api或者j2ee的api
该方法可以返回和当前Request对象所绑定的每一个属性的名字。返回的是一个枚举对象。
例如,上一个页面有多个参数传递到下一个页面,然后利用下面的代码得到,代码仅供参考:
<%
Enumeration enum=request.getAttributeNames();
while(enum.hanMoreElements())
{
String attributeName=(String)enum.nextElement();
out.print(attributeName);
%>name<br><%
String attributeValue=(String)request.getAttribute(attributeName);
out.print(attributeValue);
%>value<br><%
}%>
getAttribute("name")
该方法返回参数name所指定的属性值getParameterValues("name")
使用这个方法可以获得客户端向服务器端传送的指定参数的所有值,返回的是一个字符串数组,但是这种方法很少用。相对它来说getParameter("name")这个方法得到的是getParameterValues("name")的第一个值。setAttribute("name","value")
将参数name和它的值与当前的Request对象绑定起来,然后在下一个页面可以用getAttribute("name")得到name的值。
String param1[] = request.getParameterValues("param1");
解析出param1的值,并存放在数组中。
2.那是你的String[]的地址,应该是str_test[0],str_test[1]
3.request.getParameterValues()
Returns an array of String objects containing all of the values the given request parameter has, or null if the parameter does not exist.
返回request中所有参数的值,是一个String[],比如你这应该是"0"和"1",如果没设定就是nullgetParameterNames()
Returns an Enumeration of String objects containing the names of the parameters contained in this request
返回request中所有的参数名,是Enumeration,你这是"param1"和"param2"两个StringsetAttribute(java.lang.String name,java.lang.Object o)
Stores an attribute in this request.
在request中存储一个属性,设定它的name,o是存储的对象request.getAttribute("name");
Returns the value of the named attribute as an Object, or null if no attribute of the given name exists
取得名字为name的属性的值,如果不存在,返回nullrequest是一个在客户端和servlet传递信息的对象4.下载servlet.jar的api或者j2ee的api