Skip to content

@ModelAttribute allowed on attribute in @ModelAttribute annoted method [SPR-10913] #15541

@spring-projects-issues

Description

@spring-projects-issues

Marten Deinum opened SPR-10913 and commented

Currently it is possible to add the @ModelAttribute annotation on an argument in a method annotation with @ModelAttribute. This can lead to suprising results especially when there are multiple @ModelAttribute annotated methods.

@ModelAttribute
public Foo foo() {
}
@ModelAttribute
public Bar bar(@ModelAttribute foo) {
}

Method bar depends on foo but the execution of these methods differs from time to time.

There are 2 possible solutions I see

  1. The order of execution needs to be fixed and determined at startup/runtime, check for dependencies between methods.
  2. Don't allow this (@ModelAttribute on an attribute of a @ModelAttribute annotated method)

I would suggest option 2.


Affects: 3.2.4

Reference URL: http://stackoverflow.com/questions/18783842/annotation-modelattribute-order-of-invocation-methods/18784052

Issue Links:

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions