我用struts jspsmart实现上传下载,功能能实现,但在下载的时候tomcat服务器提示错误,错误信息: org.hibernate.TransactionException: Transaction not successfully started
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:100)
at com.news.dao.FileDAO.setHitsIncrement(FileDAO.java:88)
at com.news.filter.Down.doPost(Down.java:52)
at com.news.filter.Down.doGet(Down.java:61)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
说是Transaction not successfully started
,这是怎么回事?哪里出了问题?
down 的代码: public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
String id = request.getParameter("id");
int i = Integer.parseInt(id);
File file = FileDAO.getFileInfo(i);
String dir = request.getRealPath("/admin/upload");
String files = file.getFiletype();
SmartUpload down = new SmartUpload();
try
{
down.initialize(config, request, response);
down.setContentDisposition(null);
String more = (new StringBuilder(String.valueOf(dir))).append("/").append(file.getFilepath()).append("/").append(file.getFilename()).toString();
down.downloadFile(more, file.getFiletype(), file.getFilename(), 1024);
FileDAO.setHitsIncrement(file);
}
catch(Exception exception) { }
}
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:100)
at com.news.dao.FileDAO.setHitsIncrement(FileDAO.java:88)
at com.news.filter.Down.doPost(Down.java:52)
at com.news.filter.Down.doGet(Down.java:61)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
说是Transaction not successfully started
,这是怎么回事?哪里出了问题?
down 的代码: public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
String id = request.getParameter("id");
int i = Integer.parseInt(id);
File file = FileDAO.getFileInfo(i);
String dir = request.getRealPath("/admin/upload");
String files = file.getFiletype();
SmartUpload down = new SmartUpload();
try
{
down.initialize(config, request, response);
down.setContentDisposition(null);
String more = (new StringBuilder(String.valueOf(dir))).append("/").append(file.getFilepath()).append("/").append(file.getFilename()).toString();
down.downloadFile(more, file.getFiletype(), file.getFilename(), 1024);
FileDAO.setHitsIncrement(file);
}
catch(Exception exception) { }
}
事务没起来,你看一下你的事务配置