Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7493923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T17:14:13+00:00 2026-05-29T17:14:13+00:00

I am using spring MVC 3. I have been trying to access the attributes

  • 0

I am using spring MVC 3. I have been trying to access the attributes of the uploaded file but I keep getting the following error message. I can access the other fields of the form that is posted but I can’t access the uploaded file.

nullhandleForm - Failed to convert property value of type 'java.lang.String' to required type 
'org.springframework.web.multipart.commons.CommonsMultipartFile' for property 'file'; 
nested exception is java.lang.IllegalStateException: 
Cannot convert value of type [java.lang.String] to required type [org.springframework.web.multipart.commons.CommonsMultipartFile] 
for property 'file': no matching editors or conversion strategy found 

HTML/JSP file

<%@page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>JSP Page</title>
</head>
<body>
    <p>${Response}</p>   
    <h1>Upload Songs</h1>        
    <table>
        <form:form action="" commandName="handleForm">
        <tr>                
            <td>Song Name :</td>
            <td><form:input path="songName"/></td>                                        
        </tr>
        <tr>
            <td>Artist Name :</td>                        
            <td><form:input path="artistName"/></td>
        </tr>
        <tr>
            <td>Gendre :</td>                        
            <td><form:input path="gendre"/></td>
        </tr>
        <tr>
            <td>description :</td>
            <td><form:textarea path="description"/></td>

        </tr>
        <tr>
            <td>Browse File :</td>
            <td><form:input type="file" path="file" /></td>
        </tr>
        <tr>
            <td colspan="2" style="text-align: center"><input type="submit" value="submit" /></td>                        
        </tr>            
        </form:form>
    </table>        
</body>

The form handlerclass

public class HandleForm {

private String songName;
private String artistName;
private String gendre;
private String description;    
private CommonsMultipartFile file;


public CommonsMultipartFile getFile() {
    return file;
}

public void setFile(CommonsMultipartFile file) {
    this.file            = file;     
}

public String getArtistName() {
    return artistName;
}

public void setArtistName(String artistName) {
    this.artistName = artistName;
}

public String getDescription() {
    return description;
}

public void setDescription(String description) {
    this.description = description;
}

public String getGendre() {
    return gendre;
}

public void setGendre(String gendre) {
    this.gendre = gendre;
}

public String getSongName() {
    return songName;
}

public void setSongName(String songName) {
    this.songName = songName;
}  

}

The controller

@Controller
public class AdminController{   

@RequestMapping(value = "/admin", method = RequestMethod.GET)
public String showAdmin(){
    return "admin/index";
}


@RequestMapping(value = "/admin/upload-songs", method = RequestMethod.GET)
public String showContacts(Model model) {
    model.addAttribute(new HandleForm());
    return "/admin/upload";
}

@RequestMapping(value = "/admin/upload-songs", method = RequestMethod.POST)
public String doForm(@ModelAttribute(value = "handleForm") HandleForm handleForm, BindingResult result, Model model){

    if(result.hasErrors()){
        String stringList = null;
        List<FieldError> errors = result.getFieldErrors();
        for (FieldError error : errors ) {
            stringList += error.getObjectName() + " - " + error.getDefaultMessage() + "\n";
        }
        model.addAttribute("Response", stringList);
        //model.addAttribute("songname", handleForm.getSongName()); works fine
        //model.addAttribute("filename", handleForm.getFile().getOriginalFilename()); throws an error..?
    }       

    return "/admin/upload";
}

}

Any help would be much appreciated. Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T17:14:15+00:00Added an answer on May 29, 2026 at 5:14 pm

    do you need to add the enctype to the form declaration?

    enctype="multipart/form-data"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to post data to MVC controller action but have been unsuccessful
I have been trying to integrate Spring (3.0.4 and 3.0.5) MVC with Apache Tiles
I have been trying out the new Spring MVC 3.0 Type Conversion Framework. I
I am using Spring MVC to build my web application, and I have a
See the following Mock Test by using Spring/Spring-MVC public class OrderTest { // SimpleFormController
I am using spring web mvc for my app's UI part.. By using following
I have been trying this for a while but can't find the right solution.
I've have been using Mono Develop 2.8 on a to make an ASP MVC
I am using Hibernate in Spring MVC 3.05 and an Oracle database. I have
I have a Spring MVC app where I am using a singleton bean that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.