将html list元素与switch stament一起使用,并将列表与数据库绑定 [英] using html list elements with switch stament and binding the list with database
问题描述
我想知道如何获取html元素并将其与switch语句一起使用.
hi i want to know how to get html element and use them with switch statements.
<div id="hori">
<ul>
<li><a href="#">Aerospace</a></li>
<li><a href="#">Automotive</a></li>
<li><a href="#">Energy</a></li>
<li><a href="#">IC Engines</a></li>
<li><a href="#">IT</a></li>
<li><a href="#">Training</a></li>
<li><a href="#">Wind</a></li>
<li><a href="#">Turbo</a></li>
</ul>
</div>
<div id="verti">
<ul>
<li><a href="#1">Internal</a></li>
<li><a href="#2">Demos</a></li>
<li><a href="#3">Best Practice</a></li>
<li><a href="#4">Marketing</a></li>
<li><a href="#5">Papers & Public</a></li>
<li><a href="#6">Validation</a></li>
<li><a href="#7">Training</a></li>
</ul>
</div>
这里水平和垂直菜单将在同一页面中.例如,所有水平菜单的垂直菜单都相同.水平主菜单verti:sub菜单.
here the horizontal and vertical menus will be in the same page.the vertical menus is same for all horizontal menus for example.hori-main menus verti:sub menus.
- 航空航天:
- 内部
- 演示
- aerospace:
- internal
- demo
- 内部
- 演示
如果用户单击任何主菜单,则应相应地更改模式. 如果我单击航空航天"下的内部",则相关表应显示在同一页面中而无回发.
if the user click any of the main menus the mode should be changed accordingly. if i click internal under aerospace,related table should be displayed in the same page without postback.
这是我的jsp页面,它将显示与数据库绑定的html表
here is my jsp page which will display a html table binded with database
Class.forName("com.mysql.jdbc.Driver").newInstance();
connection = DriverManager.getConnection(connectionURL, "root", "root");
java.sql.Date sqlDate = new java.sql.Date(new java.util.Date().getTime());
psmnt1 = connection.prepareStatement("insert into file12(id,file_path,file_date) values(?,?,'"+ sqlDate+"')");
psmnt1.setString(1, concat);
psmnt1.setString(2, f.getPath());
psmnt=connection.prepareStatement("select * from file12");
rs=psmnt.executeQuery();
int s=psmnt1.executeUpdate();
if(s>0)
{
System.out.println("Uploaded successfully !");
}
else
{
System.out.println("Error!");
}
}
catch(Exception e)
{
out.print("-----------error--------------"+e);
}
%>
<table cellpadding="15" border="1">
<%
while(rs.next()){
%>
<tr>
<td><%=rs.getString(1)%> </td>
<td><%=rs.getString(2)%> </td>
<td><%=rs.getString(3)%> </td>
</tr>
<%}%>
</table>
推荐答案
如果用户单击任何主菜单,则应相应更改模式.如果我单击航空航天"下的内部",则相关表应显示在同一页面中,而无需回发.
没有回发是不可能的,jsp不是asp,在jsp中没有回发之类的东西. 尝试其他策略以实现所需的功能(例如ajax)
Without postback it's not possible, jsp is not asp , in jsp there is nothing like postback. Try some other strategy to achieve the required functionality(like ajax)
这篇关于将html list元素与switch stament一起使用,并将列表与数据库绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!