java中用a标签提交,后台怎样获取页面文本框的值

如题所述

最后是a标签里面使用onclick这个动作,然后在js里面写个function用来获取你要穿送的文本框的值,然后直接var aa = document.getElementById("aa").value; window.location.href="***.action?aa="+aa;后台用request.getParameter("aa");就可以了。
温馨提示:答案为网友推荐,仅供参考
第1个回答  2015-12-09

request.getParameter("传递的参数");

getParameter返回字符串,request.getParameter()方法是获取http提交过来的数据。

A.jsp  
<form method="post" name="form1" action="B.jsp">  
<input type="hidden" name="aa" value="aa"/>  
<input name="提交" type="submit" value="提交" />    
</form>  
B.jsp  
<%String aa=request.getParameter("aa"); %>

第2个回答  2015-10-21
JSP;

<a href="servlet/MessagesServlet?method=select&index=${num }">
MessagesServlet:
String index = request.getParameter("index");
如果是form表单的值,方法还是request.getParameter("name值");
第3个回答  2013-03-06
String str = request.getParameter("文本框ID"); 你得提交表单呐.追问

我知道啊,但是我有几个按钮,得跳到不同的方法里去,如果用表单提交的话,就只能有一个路径啊

追答

js控制跳转方法啊,每个按钮的onclock事件都设置不一样。js里控制跳转地方。
var webContext = "";
var width = 800;
var height = 450;

var method = "tdefinitionVerListVersion";
openBrWindow(webContext+'/tdefinitionVer.do?method='+method+'&key='+retKeys+extraParam+"&parentId="+retKeys,width,height,'_blank');

本回答被提问者采纳