如何从mysql数据库访问值到jsp表单 [英] how to access value from mysql database to jsp form
本文介绍了如何从mysql数据库访问值到jsp表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
i在我的jsp表单上有一个下拉控件,想要检索mysql数据库字段的值。
" Country_Id1 = rs.getString (Country_Id);"
使用我获得该值
< select name =" countryId" >
< option selected =""值= QUOT 1 QUOT;>印度< / option>
。
。
。
。
< option value =" 2">美国< / option>
< / select>
但是无法检索值表单。
请帮助我。
hi
i have one dropdown control on my jsp form and want to retrieve the value of mysql database field.
"Country_Id1 = rs.getString("Country_Id");"
using i get that value
<select name="countryId" >
<option selected="" value="1"> India </option>
.
.
.
.
<option value="2">United States</option>
</select>
but can''t able to retrieve value form table.
plz help me.
推荐答案
不要将Java代码与HTML混合使用并且当然不要将HTML与JDBC逻辑混合。
将国家/地区检索到Java类(DAO)内的方法中的Country对象列表(List< Country>)并使用该列表创建选择使用
Do not mix Java code with HTML like this and certainly do not mix HTML with JDBC logic.
Retrieve the countries into a list of Country objects (List<Country>) in a method inside a Java class (DAO) and use that list to create the select using
展开 | 选择 | Wrap | 行号
先生上面的代码无效
在最后一个语法中我以不同的方式检索值
like
< textarea name =" address" ID = QUOT;地址]按钮行= QUOT; 4英寸COLS = QUOT 35 QUOT; ><%=地址1%>< / textarea>
现在我想从数据库中检索价值
< select name = " countryId" >
< option selected =""值= QUOT 1 QUOT;>印度< /选项>
。
。
。
。
< option value =" 2"> United States< / option>
< / select>
然后我现在无法使用它...
plz指导我
sir the above code is not useful
in the last syntax i retrieve the value in different way
like
<textarea name="address" id="address" rows="4" cols="35" ><%=Address1%></textarea>
and now i want to retrieve value from database for
<select name="countryId" >
<option selected="" value="1"> India </option>
.
.
.
.
<option value="2">United States</option>
</select>
and then i can''t able now how to use that...
plz guide me
我不理解这个问题。
你想在不提交表格的情况下从数据库中获取值吗?如果是,那么使用AJAX。
I''m not understanding the question.
Do you want to get a value from the database without submitting the form? If so then use AJAX.
这篇关于如何从mysql数据库访问值到jsp表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文