首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

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

2012-01-10 
表单Value赋值为脚本变量的问题,急!jsp:includepage 2.jsp flush true /%Enumerationerequest.g

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

热点排行