jsp傳遞參數
**.jsp?param=1
那么request.getParameter("param")就可以勒!
原來用request.getAttribute死活不行,以為必須得用form傳遞呢,敢情getParameter就行~~
所以如果想只用jsp頁面的話,可以這樣子做:
hello.jsp:
function hello(name)


{
sayHello(name);
}
function sayHello(id)


{
window.location="sayHelloCommit.jsp?id="+id;
}
sayHelloCommit.jsp:

<%
@ page contentType="text/html;charset=gb2312"%>

<%
String str = (String) request.getParameter("id");
//To Something using the "str"
//redirect to a page
response.sendRedirect("hello.jsp");
%>

那么request.getParameter("param")就可以勒!
原來用request.getAttribute死活不行,以為必須得用form傳遞呢,敢情getParameter就行~~
所以如果想只用jsp頁面的話,可以這樣子做:
hello.jsp:












sayHelloCommit.jsp:













posted on 2007-08-13 16:51 cerulean 閱讀(695) 評論(0) 編輯 收藏 所屬分類: Java 、web