Home > database >  Passing in String variable to custom user details method
Passing in String variable to custom user details method

Time:05-30

I have a customer user which has a custom method which takes in a String argument/variable

    public String someCustomMethod(String stringVar) {
        return "hello "   stringVar;
    }

I am making the following call from my web page and it's working as expected (i.e. printing out "hello world"):

<span th:text="${#authentication.getPrincipal().getUser().someCustomMethod('world')}">Blah</span>

However I have a local variable ${foo} that I would like to pass in instead of hardcoded value. Can this be done? If so - how?

CodePudding user response:

The following should work (in case if you have a local variable foo defined in the scope):

<span th:text="${#authentication.getPrincipal().getUser().someCustomMethod(foo)}">Blah</span>
  • Related