jsp接收复选框参数的问题,在线等.急!
gjk11 2009-05-07 10:12:41 test.html
<html>
<head>
</head>
<body>
<form action="test2.jsp" method="post">
姓名:<input type="text" name="na" />
兴趣:<input type="checkbox" name="che" value="篮球">篮球
<input type="checkbox" name="che" value="网球">网球
<input type="checkbox" name="che" value="足球">足球
<input type="checkbox" name="che" value="游泳">游泳
<input type="checkbox" name="che" value="乒乓球">乒乓球<br>
<input type="submit" value="提交" />
</form>
</body>
</html>
test2.jsp
<%@ page contentType="text/html;charset=gbk"%>
<html>
<head>
</head>
<body>
<%
request.setCharacterEncoding("gbk");
String name=request.getParameter("na");
String xingqu[] =request.getParameterValues("che");
%>
<h1>用户名为:<%=name%></h1>
<h1>兴趣爱好:
<%
for(int i=0;i<che.length;i++)
{
%>
<%=xingqu[i]%>
<%
}
%>
</h1>
</body>
</html>
我这是按照一个视频上的代码写的,视频讲解上的可以运行,为什么我的老提示错误哪(另种写法我会可以运行,就是这段哪里出错了):
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 14 in the jsp file: /35.jsp
che.length cannot be resolved to a type
11: <h1>用户名为:<%=name%></h1>
12: <h1>兴趣爱好:
13: <%
14: for(int i=0;i<che.length;i++)
15: {
16: %>
17: <%=xingqu[i]%>