How to access constant values ​​described in java class using jstl

I want to get java constants that are declared in a separate techcontants.java java class to display in 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 tried like this <c:outvalue="${TechConstants.PART}">)

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

I use spring and jstl,

Do I need to get a constant value in my modelandview controller, do I have to pass it for viewing?

if yes, please describe to me what to do in the controller with sample code, or can I get the constants directly in jsp using jstl?

+3
source share
1 answer

You can access the properties of the object that you are binding to the form.

<form:form method="POST" commandName="user">

you can use ${user.name}

-2

All Articles