为什么我用提交按钮提交会是这样,名字输入的中文,下面的爱好后面是啥?
User:
??
frivious:[Ljava.lang.String;@24ca1465
read
swam
password:123
我的代码
request.jsp:
<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'request.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<h1>inner request</h1>
<%
String expr = new String(request.getParameter("Username").getBytes("ISO-8859-1"),"UTF-8");
request.setCharacterEncoding("utf-8");
request.setAttribute("password", "123");
%>
User: <%=expr %><br>
frivious:<%=request.getParameterValues("frivious") %><br>
<%
if(request.getParameterValues("frivious")!=null){
String[] frivious=request.getParameterValues("frivious");
for(int i=0;i<frivious.length;i++){
out.print(frivious[i]+"<br>");
}
}
%>
password:<%=request.getAttribute("password")%>
</body>
</html>
=====================================
=============req.jsp:========================
<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'req.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<form name="req" action="request.jsp" method="get">
<table>
<tr>
<td>Username</td>
<td><input type="text" name="Username"></td>
</tr>
<tr>
<td>fravious</td>
<td><input type="checkbox" name="frivious" value="read">read
<input type="checkbox" name="frivious" value="music">music
<input type="checkbox" name="frivious" value="swam">swam
<input type="checkbox" name="frivious" value="foot">foot
</td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="value"></td>
</table>
</form>
<br>
<br>
<a href="request.jsp?Username=王五">test of the URl</a>
</body>
</html>