日期:2014-05-18  浏览次数:20728 次

表单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>