JSP中提交参数除了使用表单,也可以直接在地址栏提交,这种方法叫做“地址重写”。
1.jsp
 1 <%@page contentType="text/html;charset=GB2312" %>
 2 <%
 3      request.setCharacterEncoding("GB2312");
 4 %>
 5 
 6 <html>
 7   <head>
 8     <title>1.jsp</title>
 9   </head>
10   
11   <body>
12       <%         
13           String Name=request.getParameter("name");
14       %>
15       <h1>内容:<%=Name %></h1>
16   </body>
17 </html>
直接在地址栏输入:http://localhost/web/request/1.jsp
?name=zxm
就可以显示结果。
如果传递多个参数,可以这样输入地址:localhost/web/request/1.jsp
?name=zxm
&password=123
	
posted on 2008-04-06 13:53 
冰枫逸范 阅读(550) 
评论(1)  编辑  收藏