struts2 上传的文件都是保存到临时目录下的.
如何保存到指定的目录呢,或着保存到项目工程的某个目录下.
在线等待.... 先行谢过.......

解决方案 »

  1.   

    我是这么处理的//在项目启动时候拿到绝对路径 -- 使用servlet监听
    public class ContextListener implements ServletContextListener {
        public void contextInitialized(ServletContextEvent sce) {
            String p = sce.getServletContext().getRealPath(""); //可以拿到项目绝对路劲
            Common.file = p + "\\upFile";            //为了以后可以使用我们放在全局类的静态file里面
        }
        public void contextDestroyed(ServletContextEvent sce) {
            System.out.println("=================Over=======================");
        }
    }