struts2:上传文件时如何获取文件的本地真实路径?

解决方案 »

  1.   

    String targetDirectory = context.getRealPath("/upload");
      

  2.   

    String tupi = getMyFileFileName();
      

  3.   

    我获取到的路径是C:\Program Files\Apache Software Foundation\Tomcat 6.0\work\Catalina\localhost\clkj\upload_6bdb303_12e9e6bf0bc__8000_00000000.tmp
    而我要上传的文件在f盘
    这是代码:
    <s:form action="rechargecarddaoru" method="post" namespace="/" enctype="multipart/form-data">
    <input type="file" name="upload">
    <input type="submit" value="提交">
    </s:form>String filePath = getRequest().getRealPath("/") + "upload/1.xls";
    System.out.println("post path : " + filePath);
    麻烦了
      

  4.   

    String path = ServletActionContext.getServletContext().getRealPath("/");
      

  5.   

    其实我的本意不是要上传文件的,是要读取excel的时候我想要一个动态的地址。
      

  6.   

    兄台, 你 获取客户端的动态地址干嘛 ? 难道你想用你的Java类读取 客户端的Excel内容 ?