question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to call a static method ??

See original GitHub issue

For some reason , I want to call a static method in html template , I use the code just like the example: <p th:text="${@myapp.translator.Translator@translateToFrench('textVar')}"> it’s an ordinary OGNL expression, but it does not work. I got the error like this: org.springframework.expression.spel.SpelParseException: EL1041E:(pos 29): After parsing a valid expression, there is still more data in the expression: 'bean_ref(@)' so any help here to resolve the question when I call a static method , and a method of a isntance?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:18 (1 by maintainers)

github_iconTop GitHub Comments

24reactions
saviola777commented, Apr 12, 2017

I think you want to use T() with the full class name, like

${T(com.company.package.SomeClass).staticMethod()}
0reactions
kaibadashcommented, Mar 23, 2022
[[${T(java.lang.Math).random() * 100}]]

works well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Static vs. Non-Static Methods in Java - Study.com
To create a static method in Java, you prefix the key word 'static' before the name of the method. A static method belongs...
Read more >
Static methods vs Instance methods in Java - GeeksforGeeks
Static methods are the methods in Java that can be called without creating an object of class. They are referenced by the class...
Read more >
calling static method in java [duplicate] - Stack Overflow
Static methods can be called via the classname or an instance. I would try to avoid to call them by an ...
Read more >
Master the Concept of Static Methods in Java - DataFlair
4. We can invoke a static method by using its class reference. An instance method is invoked by using the object reference. 5....
Read more >
Python Static Method Explained With Examples - PYnative
A static method is a general utility method that performs a task in isolation. Static methods in Python are similar to those found...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found