Results 1 to 3 of 3

Thread: Problems with MultipartFile Upload

  1. #1
    Join Date
    Nov 2008
    Location
    Sao Paulo, Brazil
    Posts
    21

    Cool Problems with MultipartFile Upload

    Hey guys!

    I'm trying to make an Annotation based upload controller... but with no success .

    Spring is no finding the param with the file.

    org.springframework.web.bind.MissingServletRequest ParameterException: Required org.springframework.web.multipart.MultipartFile parameter 'file' is not present
    This is my upload method on my controller:
    Code:
    @RequestMapping("/painel.upload.do")
    	public String upload(@RequestParam("file") MultipartFile file) {
    		if (file == null) {
    			System.out.println("OH NO");
    		} else {
    			System.out.println("Yes!");
    		}
    		return "painel.lista";
    	}
    And my Upload form:

    HTML Code:
    <form method="POST" enctype="multipart/form-data" action="painel.upload.do">
    		<fieldset>
    			<legend>Upload Painel</legend>
    			<table>
    				<tr>
    					<td>
    						<label>Arquivo:</label>
    					</td>
    					<td>
    						<input type="file" name="file" />
    					</td>				
    				</tr>
    				<tr>
    					<td colspan="2">
    						<input type="submit" />
    					</td>
    				</tr>
    			</table>
    		</fieldset>
    	</form>
    Is there soething missing?


    Thanks guys

  2. #2
    Join Date
    Dec 2006
    Posts
    311

    Default

    post your entire controller. I have a feeling you didnt create an instance of file on the controllers "get" handler method.

  3. #3
    Join Date
    Jan 2007
    Posts
    20

    Default

    I've had the same issue, see my post here:
    http://forum.springsource.org/showth...389#post235389

    In my case it was enough to add a CommonsMultipartResolver bean to my appliationContext.xml

    Code:
    <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver" />

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •