Spring CommonsMultipartResolver를 사용하여 파일을 업로드하려고하는데 컨트롤러가 인식되지 않습니다. 이 오류 메시지가 나타납니다 : "요청한 리소스 (/WebIDE/WEB-INF/views/file/upload.jsp)를 사용할 수 없습니다."Spring MVC 및 CommonsMultipartResolver가 예상대로 작동하지 않는 파일 업로드하기
내 라이브러리에 commons-fileupload-1.2.2.jar 및 commons-io.1.3.2.jar를 추가했습니다. 내 컨트롤러로 뽀조을 사용하고
<context:component-scan base-package="org.webide.mvc" />
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<!-- specify maximum file size in bytes -->
<property name="maxUploadSize" value="100000"/>
</bean>
을 : 내 응용 프로그램 컨텍스트에 다음을 추가 한
@Controller
@RequestMapping (value = "/file")
public class FileController {
@RequestMapping (value = "/upload")
public String uploadFile(@RequestParam("file") CommonsMultipartFile file){
if (!file.isEmpty()){
byte fileBytes[] = file.getBytes();
return "mainView";
}else{
return "errorView";
}
}
내 HTML 순간에 매우 간단합니다 :
<form method="post" action="file/upload" enctype="multipart/form-data">
<input type="text" name="name"/>
<input type="file" name="file"/>
<input type="submit"/>
</form>
수 내가 누락 된 것이 있으면 알려주시겠습니까? 감사합니다.
간단한 html의 URL은 무엇입니까? – Bozho