0

Is it possible to pass parameters to servlet/jsp using a href link? If so can anybody give an example to show how it can be done?

Thanks

4

1 回答 1

2

Of course:

<a href="link.do?user=31"/>

Read it in your servlet handling link.do URI:

public void doGet(HttpServletRequest req, HttpServletResponse resp) {
  req.getParameter("user")  //equals "31"
}

Or if it's a servlet (link.jsp):

<%= request.getParameter("user") %>

...or better with :

${param.age}
于 2012-08-18T10:56:44.747 回答