Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的jsp页面
<select name="se"> <option value="1">D1</option> <option value="2">D2</option> <option value="3">D3</option> </select>
当用户选择 D1 时,然后在同一页面中我想显示数据库中的内容。
我希望 D2、D3 也一样。
我应该在哪里编写选择查询?
您可以使用onchange事件来调用服务器。在服务器端,您可以处理请求并从数据库返回所需的结果并显示它,或者您可以在调用 jsp 时从数据库中预取结果,并且可以显示/隐藏onchange事件。
onchange
喜欢使用 jQuery
<select onchange="$('divId').show()"></select>
您可以使用onchange事件来获取选择框的值,并通过 ajax 将值传递给 servlet。
通过这个:
http://www.roseindia.net/jsp/comboSelect.shtml