Hans Desmet opened SPR-16037 and commented

Given a simple command object

package be.vdab.web;

public class CommandObject {
    private String value;

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

}

, a Controller which uses this command object:

package be.vdab.web;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping("/")
class IndexController {
    private static final String VIEW = "index";

    @GetMapping
    ModelAndView index() {
        return new ModelAndView(VIEW).addObject(new CommandObject());
    }

}

and a JSP file which works together with this controller:

<%@page contentType='text/html' pageEncoding='UTF-8' session='false'%>
<!doctype html>
<html lang='nl'>
<head>
<title>Test</title>
</head>
<body>
<%@taglib prefix='form' uri='http://www.springframework.org/tags/form'%>
<form:form action="" commandName="commandObject" method="get">
<form:input path="value"/>
</form:form>
</body>
</html>

This gives following error in Spring 5.0.0 (not in Spring 4.3.11):

org.apache.jasper.JasperException: /WEB-INF/JSP/index.jsp (line: [9], column: [0]) Unable to find setter method for attribute: [commandName]

Affects: 5.0 GA

Reference URL: https://github.com/desmethans/commandObjectError.git

Comment From: spring-projects-issues

Juergen Hoeller commented

It looks like this is a consequence of our deprecation cleanup: The commandName property has been deprecated since 4.3 (which is unfortunately hard to notice in a JSP) and removed in 5.0. Instead, you should be using modelAttribute which has been around for many years already.

I'll add a corresponding note to https://github.com/spring-projects/spring-framework/wiki/Upgrading-to-Spring-Framework-5.x

Comment From: lrozenblyum

@jhoeller sorry for raising this up, but why then the tld hasn't removed the attribute in Spring MVC5? now it's not deprecated but simply broken...

Comment From: sbrannen

Good catch, @lrozenblyum.

The code in FormTag was removed in b5db5d3aac39ca7cff4ccca491652d9490a1d175, but the commandName attribute in spring-form.tld still exists.

Thus, we simply need to remove that attribute from the TLD.

For future reference, please create a new GitHub issue when you notice something like this.

For this one, I'll create the issue for you.

Cheers!

Comment From: lrozenblyum

Thanks @sbrannen!

Comment From: sbrannen

You're welcome.

See #26337 and #26338 for the fixes in 5.2.13 and 5.3.3.