上传文件1.首先form表单的结构是正确的
表单结构主要是
<sf:form method="post" modelAttribute="user" enctype="multipart/form-data">
用户名称:<sf:input path="username"/><sf:errors path="username"/><br/>
用户密码: <sf:input path="password"/><sf:errors path="password"/><br/>
用户昵称: <sf:input path="nickname"/> <br/>
用户邮箱: <sf:input path="email"/><sf:errors path="email"/><br/>
附件:<input type="file" name="attach"/><br/>
<input type="submit" value="添加用户"/>
</sf:form>
2.<span style="font-family: Simsun; font-size: 14px; line-height: 26px; text-indent: 30px; background-color: rgb(199, 237, 204);">这里直接上传文件会报错:</span><br style="font-family: Simsun; font-size: 14px; line-height: 26px; text-indent: 30px; background-color: rgb(199, 237, 204);" /><span style="font-family: Simsun; font-size: 14px; line-height: 26px; text-indent: 30px; color: red; background-color: rgb(199, 237, 204);">Expected MultipartHttpServletRequest: is a MultipartResolver configured?</span><br style="font-family: Simsun; font-size: 14px; line-height: 26px; text-indent: 30px; background-color: rgb(199, 237, 204);" /><br style="font-family: Simsun; font-size: 14px; line-height: 26px; text-indent: 30px; background-color: rgb(199, 237, 204);" /><span style="font-family: Simsun; font-size: 14px; line-height: 26px; text-indent: 30px; background-color: rgb(199, 237, 204);">因此我们需要在hello-servlet.xml中配置这个文件解析器</span><br style="font-family: Simsun; font-size: 14px; line-height: 26px; text-indent: 30px; background-color: rgb(199, 237, 204);" /><br style="font-family: Simsun; font-size: 14px; line-height: 26px; text-indent: 30px; background-color: rgb(199, 237, 204);" /><pre name="code" class="xml" style="font-size: 14px; line-height: 26px; text-indent: 30px; background-color: rgb(199, 237, 204);"><bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"/>
3.classpath问题:当spring.xml里面的http://。。。context.asd连接不存在的时候采用classpath:、org/spring。。。。。/