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
冰楓逸范 閱讀(538)
評論(1) 編輯 收藏