jsp通过url传值

来源:百度知道 编辑:UC知道 时间:2024/06/07 19:03:00
<form action="doUpdate.jsp?id=17" name="myform">我想通过url重写把数字17传到doUpdate.jsp可是这样传不过去,我应该怎样传?

<form action="doUpdate.jsp?id=17" name="myform" method="post">//加个method="post"试试
在doUpdate.jsp里接收
<%
String id=request.getParameter("id");
%>

可以吧?在doUpdate.jsp里接收就可以了:
<%
String name=request.getParameter("id");
%>
然后你可以使用相应的方法转换为int类型——如果你需要的话。

method=""
你这个方法没有加,加上就可以

<form action="doUpdate.jsp?id=17&name=myform">

接收
String name=request.getParameter("id");