如何从ng-click - angular js?
中调用servlet中的函数我有一个servlet来使用hibernate获取数据库中所有书籍的列表。当我使用ng-click
按一个按钮时,我想从我的html页面调用该函数这是html div,我想用ng-click来调用函数
<div class="col-sm-3 bg-success" ng-click = "go('/ViewAllBooks'); ">
<h2>View All Books </h2>
</div>
这是我想要调用的
中的servlet内部的函数 public void listEmployees( ){
Configuration cfg=new Configuration();
cfg.configure("hibernate.cfg.xml");
SessionFactory factory=cfg.buildSessionFactory();
Session session = factory.openSession();
Transaction tx = null;
try{
tx = session.beginTransaction();
List books = session.createQuery("FROM Books").list();
for (Iterator iterator =
books.iterator(); iterator.hasNext();){
Books b = (Books) iterator.next();
System.out.print("First Name: " + b.getName());
System.out.print(" Last Name: " + b.getAuthor());
System.out.println("Salary: " + b.getDescription());
}
tx.commit();
}
catch (HibernateException e) {
if (tx!=null) tx.rollback();
e.printStackTrace();
}
finally {
session.close();
}
}