JSP source static fields without using scriptlets

Possible duplicate:
Link interface constant from EL

So, I have a JSP that currently does not have scriptlets in it, i.e. there are no occurrences of "<%" (except for "<% @") and instead several occurrences of "$ {javaVar}", which is an EL.

Now I need to add something like this:

<security:hasPermissionTo functionKey="<%= FunctionKeyConstants.CREATE %>" ... 

But I do not want to break the agreement on this JSP. Can I do this with EL? Or any other suggestions?

+3
source share
1 answer

Java class

public class FunctionKeyConstants{
        public static final String NAME="Jigar";
        public String getNAME(){//NOTE THAT ITS NOT STATIC
             return NAME;
        }
}

Jsp

<jsp:useBean id="cons" class="com.example.FunctionKeyConstants" scope="session"/>

then

${cons.NAME}
+4
source

Source: https://habr.com/ru/post/1776754/


All Articles