Announcement Announcement Module
Collapse
No announcement yet.
Problems with MultipartFile Upload Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    post your entire controller. I have a feeling you didnt create an instance of file on the controllers "get" handler method.

    Comment


    • #3
      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" />

      Comment

      Working...
      X