【问题标题】:reading from a file using the input type=file in grails使用 grails 中的输入 type=file 从文件中读取
【发布时间】:2012-03-16 21:20:38
【问题描述】:

您好,我的 grails gsp 中有以下代码

<form action="upload-script-url" method="post" enctype="multipart/form-data">
    <table class="table"style="width: 75%">
      <tr>
        <td>
            <span  style="font-weight: bold; ">Select the Source File:</span>
            <input size="75" type="file" id="payload" name="payload"/>
        </td>
      </tr>
      <tr>
        <td>
        <input type="submit" class="red" id="Run">Run</button>
        </td>
      </tr>
    </table>
    </form>

我从:here 读取表单参数
这些是 html 表单中的正确参数吗?
现在我应该如何继续从所选文件中读取数据?我必须使用 apache commons fileupload api 吗?
谢谢

【问题讨论】:

标签: grails file-upload groovy file-read


【解决方案1】:
request.getFile("payload")

你会得到一个CommonsMultipartFile

【讨论】:

    【解决方案2】:

    如果您花一些时间(再次)实际上look at the documentation,您将看到如何做到这一点...

    【讨论】:

    • -1 当他可以让您为他阅读并突出显示相关部分时,为什么还要麻烦文档?
    • pri_dev 的大部分问题都可以通过查看文档轻松回答。
    猜你喜欢
    • 2023-03-17
    • 2019-01-03
    • 2012-10-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-15
    相关资源
    最近更新 更多