【问题标题】:how we display values in textfields in jsp我们如何在 jsp 的文本字段中显示值
【发布时间】:2017-05-07 04:07:00
【问题描述】:

我想在 jsp 的文本字段中显示值。我已经从 jsp 页面中的数据库中获取了值,现在我想在文本字段中显示 onblur 方法调用。

    <%!Connection con; %>
<%!Statement s; %>
<%!ResultSet rs; %>
<% String cnic=request.getParameter("id");
try{
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost/test","root","");
s=con.createStatement();
rs=s.executeQuery("select * from info where cnic='"+cnic+"'");
}catch(Exception e){ e.printStackTrace(); }
%>

<% while(rs.next()) 
{ %>

<%=rs.getString("first_name")%>
<%=rs.getString("last_name")%>
<%=rs.getString("gender")%>
<%=rs.getString("cnic")%>
<%=rs.getString("date_of_birth")%>
<%=rs.getString("institute")%>
<%=rs.getString("department")%>
<%=rs.getString("degree_level")%>
<%=rs.getString("programe")%>
<%=rs.getString("year")%>

<% } %>

    <input type="text" onblur="Ajax(this.value);" />
    <input type="text"  />
    <input type="text" />

我们如何在这些文本字段中显示值

【问题讨论】:

    标签: javascript database jsp


    【解决方案1】:

    只需这样做

    <input type="text" value="<%=yourExpression%>"/>
    

    【讨论】:

    • 它不起作用,因为 while 循环在上面结束,我们无法在循环外访问
    • 那么你到底想做什么?您是否尝试在每个结果集行显示一组框或一组框?请添加更多解释。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-28
    • 1970-01-01
    • 2016-09-23
    • 1970-01-01
    相关资源
    最近更新 更多