请帮帮我,如何在JSP中显示动态树视图?
这是我的STATIC树视图:
以下是对上述输出的编码:
<li> <a href=#><span class=icon-cogs></span> Expired</a>
<ul>
<li><a href=component_blocks.html>Blocks and panels</a></li>
<li><a href=component_buttons.html>Buttons</a></li>
<li><a href=component_modals.html>Modals and popups</a></li>
<li><a href=component_tabs.html>Tabs, accordion</a></li>
<li><a href=component_progress.html>Progressbars</a></li>
<li><a href=component_lists.html>List groups</a></li>
<li><a href=component_messages.html>Messages</a></li>
<li> <a href=#>Tables<i class="icon-angle-down pull-right"></i></a>
<ul>
<li><a href=component_table_default.html>Default tables</a></li>
<li><a href=component_table_sortable.html>Sortable tables<i class="icon-angle-down pull-right"></i></a>
<ul>
<li><a href=component_layout_blank.html>Default layout(blank)</a></li>
<li><a href=component_layout_custom.html>Custom navigation</a></li>
<li><a href=component_layout_scroll.html>Content scroll</a></li>
<li><a href=component_layout_fixed.html>Fixed content</a></li>
</ul>
</li>
</ul>
</li>
<li> <a href=#>Layouts<i class="icon-angle-down pull-right"></i></a>
<ul>
<li><a href=component_layout_blank.html>Default layout(blank)</a></li>
<li><a href=component_layout_custom.html>Custom navigation</a></li>
<li><a href=component_layout_scroll.html>Content scroll</a></li>
<li><a href=component_layout_fixed.html>Fixed content</a></li>
</ul>
</li>
<li><a href=component_charts.html>Charts</a></li>
<li><a href=component_maps.html>Maps</a></li>
<li><a href=component_typography.html>Typography</a></li>
<li><a href=component_gallery.html>Gallery</a></li>
<li><a href=component_calendar.html>Calendar</a></li>
<li><a href=component_icons.html>Icons</a></li>
</ul>
</li>
但我想在Struts Framework中使用( ArrayList )从DataBase获取动态树视图的输出。
我在下面添加了编码,
我的数据库(account_dao):
我的数据库(add_customer_dao):
我的动作类(add_customer_action):
public static List getCustomerList(String customerName) {
List customerList = null;
long id = 0;
String customer_Name = new String();
try {
/*Create Session Factory Object*/
SessionFactory factory = new Configuration().configure().buildSessionFactory();
/*Creating Session Object*/
Session session = factory.openSession();
/*Creating Transaction Object*/
Transaction t = session.beginTransaction();
try {
/*Get Customer Full Name from DB where Login Name*/
Query customer_name = session.createQuery("from add_customer_dao where customerLogin=?");
customer_name.setString(0, customerName);
List Customer_Name = customer_name.list();
for (Iterator iterator = Customer_Name.iterator(); iterator.hasNext();) {
add_customer_dao Customer_Dao = (add_customer_dao) iterator.next();
customer_Name = Customer_Dao.getCustomerfullName().trim();
System.out.println("Customer Full Name : "+customer_Name);
}
} catch (Exception e) {
throw new Exception(e);
}
try {
/*Get Customer Account Id from DB*/
Query account_id = session.createQuery("from account_dao where name=?");
account_id.setString(0, customerName);
List Account_Id = account_id.list();
for (Iterator iterator = Account_Id.iterator(); iterator.hasNext();) {
account_dao Account_Dao = (account_dao) iterator.next();
id = Account_Dao.getId();
System.out.println("Account Id : " + id);
}
} catch (Exception e) {
throw new Exception(e);
}
try {
if (id != 0) {
/*Get CustomerList from DB where account_id*/
Query customer_list = session.createQuery("from add_customer_dao where accountId=?");
customer_list.setInteger(0, (int) id);
customerList = customer_list.list();
}
} catch (Exception e) {
}
} catch (Throwable ex) {
throw new ExceptionInInitializerError(ex);
}
return customerList;
}
我的bean类(add_customer_dao):
public class add_customer_dao {
private int customerId;
private int accountId;
private String customerfullName;
private String customerLogin;
private String customerPassword;
private String confirmPassword;
private String customerRole;
private String customerMobile;
private String customerTelephone;
private String customerAddress;
//Getter and Setter Methods
}
我的珠子班(account_dao):
public class account_dao {
//Declare Variable
private long loginId;
private String name;
private String password;
private String role;
//Getter and Setter Methods
}
我的jsp文件(business.jsp):
<li> <a href=#><span class=icon-pencil></span> All Customers</a>
<ul>
<%
session.setAttribute("customerList", add_customer_action.getCustomerList(account_name));
%>
<logic:iterate name="customerList" id="list">
<li><a href=form_elements.html><bean:write name="list" property="customerfullName"/></a></li>
</logic:iterate>
<!-- <li><a href=form_elements.html>Form elements</a></li>
<li><a href=form_editors.html>WYSIWYG and upload</a></li>
<li><a href=form_validation.html>Validation and wizard</a></li>-->
</ul>
</li>
请帮助我,如何显示数据库中数据的动态树视图......
先谢谢。
答案 0 :(得分:0)
升级到Struts2后(因为struts1正式弃用)。
您可以使用任何库来绘制动态树 - https://www.google.co.in/search?q=jquery+tree&oq=jquery+tree&aqs=chrome..69i57j69i65l3j69i60l2.2460j0j7&sourceid=chrome&espv=210&es_sm=122&ie=UTF-8
我过去曾使用struts2-jquery-plugin绘制动态树。