读书人

表单Value赋值为脚本变量的有关问题

发布时间: 2012-01-10 21:26:51 作者: rapoo

表单Value赋值为脚本变量的问题,急!
<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,怎么办?

[解决办法]
你把定义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>

读书人网 >Java Web开发

热点推荐