2

given an instance "myInstance" of a class offering the two following methods:

public String getAttributeValue( Identifier attribute ) {...}

and

public String getAttributeValue( ModelAttribute attribute ) {...]

Having an Identifier "myAttribute", I try to invoke the first of these two methods in my JSP:

<h2><c:out value="${myInstance.getAttributeValue(myAttribute)}" /></h2>

The problem: This works perfectly well on my dev-system, yet on the test-system I get an error, saying that an "Identifier" cannot be coerced to a "ModelAttribute".

The EL implementation chooses to call the first method on my machine, but the second method on the test machine.

Both machines are setup with current Java 7 and Tomcat 7 versions.

My question: how does the EL determine which method to call? And do I have a chance of influencing this choice (without providing an additional method)?

Thanks for any hints, Andree

Torgeist
  • 524
  • 4
  • 13
  • @BalusC Thank you, that's exactly the answer I've been looking for - a couple of years ago ;-) Should have formulated my question more concisely, though. Thumbs up! – Torgeist Nov 16 '18 at 12:33

1 Answers1

0

I don't remember well the JSP but maybe you are passing the wrong object?

vul6
  • 441
  • 4
  • 14
  • Yes, I'm passing the correct object. It's just as I described: first method with param of type "Identifier" is called on my machine, second with param of type "ModelAttribute" is called on the other. I have found no clues in the specs of EL 2.2 concerning the way the method to invoke is chosen in the described case - and no description of a limitation in this matter. – Torgeist Nov 03 '14 at 18:58