jsp中在页面用java代码取hidden变量
来源:百度知道 编辑:UC知道 时间:2024/06/13 03:12:05
如何实现,请指教!
我的页面是不转向的,就在本页取本页的隐藏变量值,不提交页面
我不能用javascript,
struts标签里的logic:equal 能用javascript么
我的页面是不转向的,就在本页取本页的隐藏变量值,不提交页面
我不能用javascript,
struts标签里的logic:equal 能用javascript么
hidden和其他元素是一样的,可以在类似servlet或Struts的action中用request.getParamter("name")来获取。
name就是你的hidden的元素的name属性。
那就用js来做
document.getElementById("id").value;
新建一个index.jsp内容如下
<body >
<form name="form1" action="index.jsp?temp =324" method="post" >
<input type="text" name="test1" value="test" >
<%
String strTest = (String)request.getParameter("test1") ;
%>
<input type="text" name="test2" value="<%=strTest%>">
<input type="submit" name="testBotton" value="Get it!!" >
</form>
</body>
如果页面保持静态,是不可能取到的,你可以走条弯路,当test1内容有变化的时候,就提交这个页面并把URL再指向这个页面一遍。我写的测试程序里直接写了一个botton来提交这个表单。
request.getAttribute("变量名")
就可以取
本页的话就是