抄都能抄錯,而且還找不到錯在哪。
為什么愛好輸出錯誤。on ?選了幾個就有幾個on,卻不能輸出愛好名。
? <body>
? ? <h1>request內置對象</h1>
? ? <%request.setCharacterEncoding("utf-8"); %>
? ? <hr>
? ? 用戶名:<%=request.getParameter("username")%><br>
? ??
? ? 愛好:<%?
? ? String[] favorites=request.getParameterValues("favorite");
? ? if(request.getParameterValues("favorite")!=null){
? ? for(int i=0;i<favorites.length;i++)
? ? {
? ? out.println(favorites[i]+" ");
? ? }
? ? }
? ? ?%>
?
? </body>
? <body>
? ? <h1>out內置對象</h1>
? ? <hr>
? ? ?<h1>用戶注冊</h1>
? ? <hr>
? ? <form name="regForm" action="request.jsp" method="post">
? ? <table>
? ? <tr>
? ? <td>用戶名</td>
? ? <td><input type="text" name="username"/></td>
? ? </tr>
? ? <tr>
? ? <td>
? ? <input type="checkbox" name="favorite" values="read">讀書
? ? <input type="checkbox" name="favorite" values="music">音樂
? ? <input type="checkbox" name="favorite" values="movie">電影
? ? <input type="checkbox" name="favorite" values="internet">上網
? ? </td>
? ? </tr>
? ? <tr>
? ? <td colspan="2"><input type="submit" values="提交"/></td>
? ? </tr>
? ? </table>
? ? </form>
?<br><br>
?<a href="request.jsp?username=歷史">測試url傳參數</a>
? </body>
2015-01-25
?<input type="checkbox" name="favorite" values="read">讀書
給元素賦值,沒有用values,是value,不要加s