表单Value赋值为脚本变量的问题,急!

fanrong330 2007-05-15 06:55:33
<jsp:include page="2.jsp" flush="true"/>
<%
Enumeration e=request.getAttributeNames();
while(e.hasMoreElements()){
String attributeName=(String)e.nextElement();
String attributeValue=(String)request.getAttribute(attributeName);
out.print("变量名称:"+attributeName);
out.print("变量内容:"+attributeValue+"<BR>");
}
%>
<form method="POST" action="login.jsp">
<input type="hidden" name="Seed" >
<input type="submit" value="Submit" name="submit" >
</form>
我想把隐藏表单Seed的Value赋值为脚本里的变量attributeValue,怎么办?
...全文
351 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
awusoft 2007-05-15
  • 打赏
  • 举报
回复
好好学
fanrong330 2007-05-15
  • 打赏
  • 举报
回复
唉,终于解决问题了!
十分感谢 AWUSOFT!!!!
awusoft 2007-05-15
  • 打赏
  • 举报
回复
你把定义String attributeValue放在while外边就可以了

String attributeName="";
String attributeValue="";
Enumeration e=request.getAttributeNames();
while(e.hasMoreElements()){
attributeName=(String)e.nextElement();
attributeValue=(String)request.getAttribute(attributeName);
out.print("变量名称:"+attributeName);
out.print("变量内容:"+attributeValue+"<BR>");
}


<form method="POST" action="login.jsp">
<input type="hidden" name="Seed" value="<%=attributeValue%>" >
<input type="submit" value="Submit" name="submit" >
</form>
fanrong330 2007-05-15
  • 打赏
  • 举报
回复
一楼那是错误的,我在2楼已经说了。
awusoft 2007-05-15
  • 打赏
  • 举报
回复
一楼的给你回答了阿
fanrong330 2007-05-15
  • 打赏
  • 举报
回复
我的想法就是把java脚本里的值赋给隐藏表单,然后通过表单提交给服务器
awusoft 2007-05-15
  • 打赏
  • 举报
回复
只能提交给服务器,没 有在一个页面里把HTML的值给JAVA的
fanrong330 2007-05-15
  • 打赏
  • 举报
回复
提示错误 “ attributeName cannot be resolved ”
好像变量attributeName的作用域只是在脚本里。
li_d_s 2007-05-15
  • 打赏
  • 举报
回复
<input type="hidden" name="Seed" value="<%=attributeValue%>">

81,114

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧