Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access constant values described in java class using jstl

I want get java constants which declared in seperate java class techcontants.java, to be displayed in the jsp using jstl.

public class TechConstants {
   public static final String PART = "Part";
   public static final String DESCRIPTION = "Description";
   public static final String VERSION = "Version";
}

In my view.jsp i need this value like this using ustl

<td class="Thd" width="14%">Part</td>

(i have tried like this <c:outvalue="${TechConstants.PART}">)

<td class="Thd" width="20%">Description</td>
<td class="Thd" width="10%">Version</td>

I am using spring and jstl,

Do i need to get the constant value in my modelandview controller from there i have to pass it to view?

if so please describe me in what to do in controller with code example, or i can get constants directly in jsp using jstl?

like image 846
anto Avatar asked Jul 25 '26 02:07

anto


1 Answers

You can do it using JSP expression tag ,Please give a try with below code.

<%=TechConstants.PART %>
like image 191
Alien Avatar answered Jul 28 '26 15:07

Alien



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!