Я использую Hibernate и jsp для написания системы блогов.Я хочу использовать фильтр для управления сеансом и транзакциями.теперь я пишу фильтр:
public class SessionFilter implements Filter {
FilterConfig config;
SessionFactory sessionFactory;
Session session;
public void destroy() {
session.getTransaction().commit();
this.config=null;
System.out.println("session Filter is destroyed.");
}
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
sessionFactory = (SessionFactory) config.getServletContext().getAttribute("sessionFactory");
session = sessionFactory.getCurrentSession();
session.beginTransaction();
chain.doFilter(request, response);
}
public void init(FilterConfig config) throws ServletException {
this.config=config;
System.out.println("session Filter is inited.");
}
}
теперь результат - мои поля формы не сохраняются в mysql.