-
Apr 19th, 2007, 12:56 AM
#1
command object is coming null when i am using multipart resolver for file uploading
this the code that i am writing in my application context(xyz-servlet.xml)
<bean id="multipartresolver"
class="org.springframework.web.multipart.commons.C ommonsMultipartResolver"><!--
one of the properties available; the maximum file size in bytes
--><property name="maxUploadSize" value="1000" />
</bean>
controller part---simple form controller
public class RelReqExcelApprovalController extends SimpleFormController{
public RelReqExcelApprovalController(){
setCommandClass(FileUploadBean.class);
setCommandName("FileUploadBean");
}
protected ModelAndView onSubmit(
HttpServletRequest request,
HttpServletResponse response,
Object command,
BindException errors) throws ServletException, IOException {
FileUploadBean bean = (FileUploadBean) command;
MultipartFile file = bean.getFile();
System.out.println("bean file//////////"+file);//this is coming null
}
}
// my form bean class
public class FileUploadBean {
private MultipartFile file;
public void setFile(MultipartFile file) {
this.file = file;
}
public MultipartFile getFile() {
return file;
}
}
this is all i am doing but mycommand object is coming null.
-
Apr 19th, 2007, 03:19 AM
#2
Have you added enctype="multipart/form-data" to your form?
Jörg
-
Apr 19th, 2007, 03:35 AM
#3
yes i have added.....it seems to be that its not actually the problem of multipart resolver even if i am trying to fetch string feild than also it is coming null
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules