我要表单采用get方式提交信息。表单如下:
<%@ page contentType="text/html;charset=gb2312" language="java" %>
<html>
<head>
<title>收集参数的表单页</title>
</head>
<body>
<form id="form1" method="get" action="request1.jsp">
用户名:<br>
<input type="text" name="name"><hr>
性别:<br>
男:<input type="radio" name="gender" value="男">
女:<input type="radio" name="gender" value="女"><hr>
喜欢的颜色:<br>
红:<input type="checkbox" name="color" value="红">
绿:<input type="checkbox" name="color" value="绿">
蓝:<input type="checkbox" name="color" value="蓝"><br>
来自的国家:<br>
<select name="country">
<option value="中国">中国</option>
<option value="美国">美国</option>
<option value="俄罗斯">俄罗斯</option>
</select><hr>
<input type="submit" value="提交">
<input type="reset" value="重置">
</form>
</body>
</html>request1.jsp代码如下:
<%@ page contentType="text/html;charset=gb2312" language="java" errorPage="" isErrorPage="true"%>
<html>
<head>
<title>获取请求参数</title>
</head>
<body>
<%
String rawName = request.getParameter("name");
byte[] rawBytes = rawName.getBytes("ISO-8859-1");
String name = new String(rawBytes,"gb2312");

String rawGender = request.getParameter("gender");
byte[] rawBytees = rawGender.getBytes("ISO-8859-1");
String gender = new String(rawBytees,"gb2312");

String[] color = request.getParameterValues("color");
String national = request.getParameter("country");
%>
您的名字:<%=name%><hr>
您的性别:<%=gender%><hr>
您喜欢的颜色:<%for(String c:color) {out.println(c + " "); } %><hr>
您来自的国家:<%=national%><hr> 
</body>
</html>
问题出现了,姓名和性别可以接收到中文了,但下面选的颜色我怎么让它全部显示出来呢?还有如果性别和颜色不选的话,就出出错,请问怎么解决呢?