Put the hibernate of the package into the Web application lib, and then define the Hibernate.cfg.xml, which is the configuration information of the plug-in, as follows
<?xml version= "1.0" encoding= "UTF-8"? ><! DOCTYPE hibernate-configuration Public "-//hibernate/hibernate configuration dtd//en" "http:// Hibernate.sourceforge.net/hibernate-configuration-2.0.dtd ">
</session-factory>
Import Org.apache.struts.action.plugin;import Org.apache.struts.action.actionservlet;import Org.apache.struts.config.moduleconfig;import Javax.servlet.servletexception;import Javax.servlet.ServletContext; Import Net.sf.hibernate.sessionfactory;import Net.sf.hibernate.cfg.configuration;public class HibernatePlugIn implements PlugIn { public void Destroy () { } public void init (Actionservlet servlet, Moduleconfig config) throws servletexception { try { ServletContext context = Servlet.getservletcontext (); Sessionfactory SF = new Configuration (). Configure (). Buildsessionfactory (); Context.setattribute ("Net.sf.hibernate.SessionFactory", SF); } catch ( Exception ex) { ex.printstacktrace (); } }}} corresponding, To configure plug-in information in the Struts-config.xml, probably as follows, note the path
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.