当前位置: 代码迷 >> Java Web开发 >> 怎么样获取文本中的动态值......
  详细解决方案

怎么样获取文本中的动态值......

热度:68   发布时间:2010-04-01 16:10:37.0
怎么样获取文本中的动态值......
       <%for(int hh=0;hh<aa;hh++){%>




        <%while(rs1.next()){%>
       <%for(int q=0;q<aa;q++){%>
       <p><%=AllData[hh] %><input type="hidden" name="name_<%=q%>" value="<%=rs1.getString(q+1)%>"/></p>

      

<%}%>

         <%}%>
<%}%>
在另外一个页面中获取name中的值怎么样获取呀!
搜索更多相关主题的帖子: 获取  文本  动态  

----------------解决方案--------------------------------------------------------
你的程序不完整,我猜你是传一组数据,先将数据保持在request中,再从另一个页面中取出request的数据并显示出来

[ 本帖最后由 lampeter123 于 2010-4-1 16:27 编辑 ]
----------------解决方案--------------------------------------------------------
同意楼上的
建议你修改代码,因为像你那样的话,name的属性值是随p的变化而变化的,jsp无法识别
修改如下
<input type="hidden" name="name" value="<%=rs1.getString(q+1)%>"/>
在另一个页面获取name的值
String name[]=request.getParameterValues("name");
for(int i=0;i<name.length;i++)
{
out.print(name[i]+",");
}
----------------解决方案--------------------------------------------------------
<%--
    Document   : index
    Created on : 2010-3-6, 22:25:14
    Author     : linyan
--%>

<%@page contentType="text/html" pageEncoding="gbk"%>
<%@page language="java" import="java.util.*"%>
<%@page import="java.sql.*"%>
<%@page import="myjsp.Select"%>
<jsp:useBean id="xxx" scope="session" class="myjsp.Conn"/>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
  <head>
    <title>bb1</title>

    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=gbk">

    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->

  </head>
<body>

<%
        Select conn1=new Select();

        String id=request.getParameter("id");
     String lie=request.getParameter("lie");
     String tableid=request.getParameter("tableid");

        String strSql1="select * from "+id+" where "+lie+"="+tableid+"";
        ResultSet rs1=conn1.doQuery(strSql1);
        %>
    <%
        Select conn=new Select();
        String strid=request.getParameter("id");
        String strSql="select * from "+strid+"";
        ResultSet rs=conn.doQuery(strSql);
        %>
        <%
        String[] AllData=conn.DB2(rs);
        ResultSetMetaData rsmd = rs.getMetaData();
        int aa=rsmd.getColumnCount();%>
        <%
        
     String request_page_s=request.getParameter("page");

     int request_page;  //当前页
     int pageSize=10;

     try{
      if(request_page_s.length()==0)
       request_page=1;
      else
       request_page=Integer.parseInt(request_page_s);
     }
     catch(Exception e)
     {
      request_page=1;
     }
     Vector vector=xxx.getResult(pageSize,request_page,"select * from "+id+"");

%>

    <center>
        <form id="form1" name="form1" method="post" action="update2.jsp?tableid=<%=tableid%>&lie=<%=lie%>&id=<%=id%>">//传递参数
<tr>

       <%for(int hh=0;hh<aa;hh++){%>




        <%while(rs1.next()){%>
       <%for(int q=0;q<aa;q++){%>
       <p><%=AllData[hh] %><input type="text" name="<%=AllData[hh++] %>" value="<%=rs1.getString(q+1)%>"/></p>


<%}%>

         <%}%>
<%}%>
            
        </tr>
      
        qq<input type="text" name="tian" value=""/>//测试固定值用
    <input type="submit" name="Submit" value="确定" />

</form>
    </center>

</body>
</html>
这个是我要修改的界面。
----------------解决方案--------------------------------------------------------
<%--
    Document   : update2
    Created on : 2010-3-31, 22:29:08
    Author     : linyan
--%>

<%@page contentType="text/html" pageEncoding="gbk"%>
<%@page language="java" import="java.util.*"%>
<%@page import="java.sql.*"%>
<%@page import="myjsp.Select"%>
<%@page import="myjsp.test"%>
<jsp:useBean id="xxx" scope="session" class="myjsp.Conn"/>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
  <head>
    <title>bb1</title>

    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=gbk">

    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->

  </head>
<body>

<%
        

        String id=request.getParameter("id");
     String lie=request.getParameter("lie");
     String tableid=request.getParameter("tableid");
String  str="";
  str=request.getParameter("strIndex");
  out.print(str);
  %>

  <%
String tt=request.getParameter("tian");


out.print(tt);
%>

<%
Select conn1=new Select();
String strSql1="select * from "+id+" where "+lie+"="+tableid+"";
        ResultSet rs1=conn1.doQuery(strSql1);
        %>


    <%
        Select conn=new Select();
        String strid=request.getParameter("id");
        String strSql="select * from "+strid+"";
        ResultSet rs=conn.doQuery(strSql);
        %>

        <%
        String[] AllData=conn.DB2(rs);
        ResultSetMetaData rsmd = rs.getMetaData();
        int aa=rsmd.getColumnCount();%>

       <%for(int hh=1;hh<aa;hh++){%>
      
       <%=AllData[hh] %>
                <%}%>
</body>
</html>
这个是我要处理修改的页面
----------------解决方案--------------------------------------------------------
我是要获取数据库修改后的值,而不是从数据库中的值
----------------解决方案--------------------------------------------------------
你这样做没有必要,把你要做修改的页面写成业务类,然后在你要做修改的页面中import进来就可以了,这是常见的做法,将数据处理,也就是业务与显示分离开来,不要把业务处理写成一个没有页面显示的jsp文件。

如果你像你这样做的话,可以把你要做修改的页面使用include指令包含进前一个页面中就可以了。

个人还是建议前一种。
----------------解决方案--------------------------------------------------------
对不起我只是想去简单的获取已经修改好的动态文本值,其他的没有别的啦!谁能教教我呀!
----------------解决方案--------------------------------------------------------
  相关解决方案