我有以下JSP代码:
<%
for (int i = 0; i < list.size(); i++) {
Entry var = (Entry) list.get(i);
//[...]
String Cn = var.getCn();
out.println(" <form method=\"get\" action=\"NewServlet\"> "+ "<input \
type=\"submit\" name=\"act\" value=\" " + var.getCn() + " \" > " + "</form>");
out.println("<br>--------------------<br>");
}
%>
我想将参数var.getCn()
发送到servlet,但我不知道如何从servlet中捕获它。我怎么能这样做?
//[....]
String Cn = new String();
Cn = request.getParameter("???");
//[....]
答案 0 :(得分:0)
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String foo = request.getParameter("foo");
String bar = request.getParameter("bar");
// Do something with foo & bar.
}
网址:
http://example.com/myservlet/?foo="hey"&bar="funny"
阅读more。