今天就遇到了这个问题,因为在提交数据时,有时候需要上传文件,有时候不需要。偷懒了一下,没有做任何判断,直接给 form 添加了 enctype=”multipart/form-data” 这个属性。
在测试环境还好,一切正常。等部署到生产环境后,发生了一个稀奇古怪的空指针异常,看上去没有任何理由应该会发生这个错误。
排查开始…………(省略30k+的辛苦描述)。最后发现问题的根源就在 enctype=”multipart/form-data” 这里。
大家记住了,如果没有上传文件,千万不要随便给 form 乱加 enctype=”multipart/form-data” 属性。

Leave a Reply

Your email address will not be published. Required fields are marked *

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax

This site uses Akismet to reduce spam. Learn how your comment data is processed.