Results 1 to 3 of 3

Thread: Injecting properties to JSP

  1. #1
    Join Date
    Nov 2009
    Posts
    24

    Default Injecting properties to JSP

    Hello
    Is there any possibility to use properties file values (like this below), in JSP file?
    Code:
    <util:properties id="filepaths" location="classpath:filepaths.properties"/>
    I want to use it in this way (for example):
    Code:
    <a href="${filepaths.thumb}">Thumb</a>
    Thanks in advance for your answer!

  2. #2
    Join Date
    Mar 2010
    Posts
    26

    Default

    You cant do this directy as JSP have no access to the spring context, however you can do this manually by using the ServletContext to register and access the properties object with setAttribute and getAttribute.

  3. #3
    Join Date
    Mar 2010
    Location
    USA
    Posts
    119

    Default

    Hi

    Am using velocity for my project and I use $springMacroRequestContext.getMessage(parameters) to get the string from the resource bundle which I have configured using a messageSource bean of type org.springframework.context.support.ReloadableReso urceBundleMessageSource.

    But in JSP, I think you can get the Spring's Request Context and then use the getMessage() method to get the string from a property file if I am right!!

    Priya
    Last edited by priyavenkat; Mar 31st, 2010 at 12:05 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •