0
양식을 다른 일반적인 필드와 함께 제출할 수는 있지만 양식의 그림을 선택하면 제출이 성공하지만 선택하지 않으면봄에 파일을 선택하지 않고 양식을 제출하지 못했습니다.
@RequestMapping(value="/register", method=RequestMethod.POST)
public String processRegistration(
@RequestPart("profilePicture") byte[] profilePicture,
@Valid Spitter spitter, Errors errors)
{
System.out.println("SpitterController.processRegistration is called first time");
if (errors.hasErrors())
{
System.out.println("find errors");
return "registerForm";
}
System.out.println("SpitterController.processRegistration is called");
System.out.println(spitter.toString());
spitterRespository.saveSpitter(spitter);
return "redirect:/spitter/"+spitter.getId();
}
: 여기
<%@ taglib prefix="sf" uri="http://www.springframework.org/tags/form" %>
<sf:form method="POST" modelAttribute="spitter" enctype="multipart/form-data">
<sf:errors path="*" cssClass="error" element="div"></sf:errors><br/>
<sf:label path="id" cssErrorClass="error">User ID:</sf:label> <sf:input path="id" cssErrorClass="error" /><sf:errors path="id" /> <br />
<sf:label path="firstName" cssErrorClass="error">First Name: </sf:label><sf:input path="firstName" cssErrorClass="error"/><sf:errors path="firstName" cssClass="error" /> <br/>
<sf:label path="lastName" cssErrorClass="error">Last Name: </sf:label><sf:input path="lastName" cssErrorClass="error"/><sf:errors path="lastName" cssClass="error"/> <br/>
<sf:label path="password" cssErrorClass="error">Password: </sf:label><sf:password path="password" cssErrorClass="error"/><sf:errors path="password" cssClass="error"/> <br/>
<br />
<label>Profile Picture</label>
<input type="file" name="profilePicture"
accept="image/jpeg,image/png,image/gif" /><br />
<input type="submit" value="Register" />
</sf:form>
내 컨트롤러 방법 :
이
Type Status Report
Message Required request part 'profilePicture' is not present
Description The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).
Apache Tomcat/8.5.23
내 JSP 코드를 참조 : 사진은 제출 400 오류가 발생합니다
이 문제를 해결하는 방법에 대해 잘 모르고 그 이유를 모르는 사람이 나를 도울 수 있습니까?
감사합니다, 지금 일하고있어 – user2575502