本帖最后由 c20110924001 于 2011-09-24 17:57:05 编辑

解决方案 »

  1.   


    <%
      String imagePath = request.getParameter("A");  
      String path=InetAddress.getLocalHost().getHostAddress();
      path="http://"+path+":8080";
      String xx=path+"/vegetable/"+imagePath;
    %>
    <img src="<%=path%>/vegetable/<%=imagePath%>" />FormFile formFile = (FormA) form.getFile();
    String fileName = formFile.getFileName();
    String photo = ""; if (fileName != null && !"".equals(fileName)) {
    photo = "images/" + fileName;
    String imagePath = ResourceUtils.getMessage("OrderFood.photo.path");
    File file = new File(imagePath);
    if (!file.exists()) {
    file.mkdir(); } else {
    FileOutputStream fos = new FileOutputStream(imagePath
    + "//images//" + formFile.getFileName()); fos.write(formFile.getFileData());
    fos.flush();
    fos.close();
    formFile.destroy();
    } }试试看吧
      

  2.   

    String imagePath = request.getParameter("A"); 
    大哥,你这里直接是参数传来的
    我问的是这个标签中的文件绝对路径<s:file name="myFile">这里的myFile这个文件的绝对路径我怎么把它取出来,不论是在前台页面还是后台action,怎么取?
      

  3.   

    jsp页面代码:    
    <form action="test.action">
    <s:file name="myFile" value="浏览..."></s:file>
    <input type="submit" name="submit" value="上传"/>
    </form>
    现在就是想把这个选中的文件的绝对路径,比如我选取了一个c盘下的文件1.txt,我想把c:/1.txt这个字符串取出来,这个信息在jsp界面上可以看得到,怎么取?求教高手
      

  4.   

    看看s:file有没有相应的属性。
    不过估计是得不到文件路径。
      

  5.   

    我说下思路,在<s:file>里添加onchange事件,通过JS把<s:file>内的值传到一隐藏域,同时提交到服务端就OK了。
      

  6.   

    我说下思路,在<s:file>中添加onchange事件,通过触发onchange事件传递<s:file>中的值到一隐藏域,一起提交到服务端就OK了。