我試圖使用提交按鈕將2個參數userId
和friendId
,使用jsp傳入同一個servlet。我能夠獲得friendId
,但是,我無法獲得userId
。使用onclick事件將2個參數提交到同一個servlet中
function anotherPageServlet(servletName) {
document.forms[0].method = "post";
document.forms[0].action = servletName;
document.forms[0].submit();
}
function anotherPageServlet1(servletName) {
document.forms[0].method = "post";
document.forms[0].action = servletName;
document.forms[0].submit();
}
<input style="color:#3333ff"
type="submit"
class="rsubmit"
value="<%= retrieving.getDisplayname()%> :"
onclick="anotherPageServlet('ViewingFriendServlet?stringParameter=<%= session.getAttribute("userId") %>'),
anotherPageServlet1('ViewingFriendServlet?stringParameter=<%=retrieving.getoID() %>')"
>
有你有兩個相同的JS功能有特殊原因? –
@Hubert Grzeskowiak沒有理由。我主要的動機是將2個參數userId和friendId一起傳遞給servlet。 – qcc