Java中一个页面的超链接<a href="xxx.action?id=1"⼀>在xxxAction类中怎么获取这个传递的Id?急

2025-05-20 22:10:50
推荐回答(5个)
回答1:

1,如果你没用struts2框架的话,request.getAttribute("id")
2,如果你使用了struts2框架的话,你只用在action中设置一个叫id的属性,并给它get,set方法(这里只会用到get方法)。struts2框架会自动赋值你的id属性,你直接使用就可以了。

回答2:

request.getParameter("id")就可以直接获取id。

回答3:

String id = ServletActionContext.getRequest().getParameter("id");

回答4:

request.getParameter("id")

回答5:

request.getParame("id")