----------------解决方案--------------------------------------------------------
我想用id传,然后在接收页收,不过我是用for下的 .getString();来显示所有的内容的,但是因为for的原因id在传送的值总是最后的那个值,所以这点才是我最晕的。
怎么解决啊?
----------------解决方案--------------------------------------------------------
for循环怎么只会得到最后一个值呢?
----------------解决方案--------------------------------------------------------
forward 不行么
----------------解决方案--------------------------------------------------------
for得到全部的值,但是我把值给id后,for结束id的值就是最后的那个了,其实这问题应该是一个传多值问题吧?就是传多值到接收的页面
----------------解决方案--------------------------------------------------------
forward?
是怎么用的啊?
----------------解决方案--------------------------------------------------------
public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException{
String[] parms=request.getParameterValues("ids");
for(int i=0;i<parms.length;i++){
}
}
在你的servlet中这样写就可以了。
不过你在页面要过滤一下哪些被选中。
----------------解决方案--------------------------------------------------------
forward?
是怎么用的啊?
是一个标签,可以转到其他的页面.page属性
----------------解决方案--------------------------------------------------------
我把代码给帖上来吧:
<%
String id="";//id 是一个编号
String username="";
String password="";
String url="jdbc:odbc:NewSchoolArea2";
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(Exception e){out.println("驱动程序未找到!");}
Connection con=DriverManager.getConnection(url,username,password);
Statement conn=con.createStatement();
ResultSet rs=conn.executeQuery("select * from 公告 order by 日期 DESC");
if(rs.next())
{%>
<marquee onmouseover="this.stop()" onmouseout="this.start()" scrollamount="2" direction="up" >
<%
for(int i=0;i<20;i++)
{%>
<a href="admin/news.jsp;" target="_parent" class="STYLE126"> <%=("☆"+rs.getString("公告名"))%></a>
<%
//上面的代码运行起来后,数据库中的公告名就全显示出来了.这时如果你点哪一条,那么就会转到admin/news.jsp去,news.jsp里就select 内容 where 编号=id.我就想知道,这个id怎么弄来,数据库中有 编号 这属性.
try{
if(!rs.next()){break;}
}catch(Exception e){}
}}%>
谢谢各位!
----------------解决方案--------------------------------------------------------
10楼正解
----------------解决方案--------------------------------------------------------