抄都能抄錯(cuò),而且還找不到錯(cuò)在哪。
為什么愛(ài)好輸出錯(cuò)誤。on ?選了幾個(gè)就有幾個(gè)on,卻不能輸出愛(ài)好名。
? <body>
? ? <h1>request內(nèi)置對(duì)象</h1>
? ? <%request.setCharacterEncoding("utf-8"); %>
? ? <hr>
? ? 用戶名:<%=request.getParameter("username")%><br>
? ??
? ? 愛(ài)好:<%?
? ? 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內(nèi)置對(duì)象</h1>
? ? <hr>
? ? ?<h1>用戶注冊(cè)</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">音樂(lè)
? ? <input type="checkbox" name="favorite" values="movie">電影
? ? <input type="checkbox" name="favorite" values="internet">上網(wǎng)
? ? </td>
? ? </tr>
? ? <tr>
? ? <td colspan="2"><input type="submit" values="提交"/></td>
? ? </tr>
? ? </table>
? ? </form>
?<br><br>
?<a href="request.jsp?username=歷史">測(cè)試url傳參數(shù)</a>
? </body>
2015-01-25
?<input type="checkbox" name="favorite" values="read">讀書
給元素賦值,沒(méi)有用values,是value,不要加s