Announcement Announcement Module
Collapse
No announcement yet.
How can I directly access util:properties in JSP? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How can I directly access util:properties in JSP?

    HTML Code:
    <util:properties id="myProperties" location="classpath:myProps.properties"></util:properties>
    I want to access them as

    HTML Code:
    <a href="${myProperties['WEB_CLIENT_URL']}" target="_blank"></a>
    but I don't get the property in JSP.

    Note: I don't want to get them set to a property either to the Model or in a DTO/Form and then use it.

  • #2
    I don't want to get them set to a property either to the Model or in a DTO/Form and then use it
    and why is that? Are you holding a grudge against the mvc programming pattern?

    Preparing the model for your view is the Controller's duty. Obtaining the data to build the model is the Service duty. You should use a service to retrieve those properties, inject that service in your controller, add the result to your model, use that model in the jsp.

    If you don't go this way, you are working against the framework so don't hope that the framework will come to your help with an instrument to accomodate your needs...just write a custom tag that reads the properties file directly and outs the value for a certain key directly in the jsp (did I just say that? I'm disgusted at my own non-mvc non-Spring solution....)

    Comment


    • #3
      It's not like I hold a grudge against MVC , the reason is why do I need to store an external site's link which comes from the properties in my Model/DTO/Form.

      Writing my own tag-lib when there are so many existing which can do the work, I wouldn't do that.

      Coming back to the point, I was also informed by my colleague that it may not be good to make all the properties available for the View (some of the properties are secure information).

      Comment

      Working...
      X