gpt4 book ai didi

jsp - upload file error , -参数类型不匹配-

转载 作者:行者123 更新时间:2023-12-03 18:33:47 27 4
gpt4 key购买 nike

在我的 jsp 中,我有一个 html:file像这样,在形式中我有 getter 和 setter。但是在运行时我得到了

Caused by: java.lang.IllegalArgumentException: Cannot invoke com.app.app.struts.forms.MyForm.setDocfile on bean class 'class com.app.app.struts.forms.MyForm'
- argument type mismatch - had objects of type "java.lang.String" but expected signature "org.apache.struts.upload.FormFile"

jsp:
<html:file property="docfile" styleId="docfile" size="45" ></html:file>

仅在提交页面时出现错误并且我没有上传任何内容。 (上传字段不是必填字段。)

最佳答案

好像是编码有问题,struts 表单不能将提交识别为文件类型,请确保将表单的 enctype 属性设置为 multipart/form-data和方法为 post .

所以你应该有:

<html:form action="/somePath" enctype="multipart/form-data" method="post"></html:form>

请注意,这可能会使您的验证变得困惑。见 this线程更多。

关于jsp - <html :file> upload file error , -参数类型不匹配-,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14261379/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com