Question

I have the following code to set a userId variable:

(userId set in prior code)

<c:set var="userId" value="(Cust#${userId})" />

Which produces the following string: (Cust#${userId})

The following code works as expected, however:

<c:set var="userId" value="(Cust# ${userId})" />

displays the following string (Cust# 0001) .

Why does the '#' character before a '${string}' expression prevent the string from being evaluated? Is there a work around I could use that doesnt involve having to insert a space?

Was it helpful?

Solution

Since JSF would use:

#{userId}

To return a user Id, I would venture to guess that this is either a bug or expected behavior caused by the # sign making the parser unhappy. Just use either of:

<c:set var="userId" value="(Cust&#35;${userId})" />
<c:set var="userId" >(Cust&#35;${userId})</c:set>

OTHER TIPS

I tested the above and it does not work. Its ouput would be:

Cust#0002 or whatever.

You can use an escape to get it to work right though. For example:

<c:set var="userId" value="(Cust\#${userId})" />

The output is:

Cust#0002

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top