Java Ninja Chronicles By Norris Shelton

Things I learned in the pursuit of code

I have a Springframework project that had a property value that contained the host of the server that I was going to be deployed on. There was more to it, because there were profiles, etc, but that is the gist of it. There is a value in a property file that I need.

The properties file was declared as:

<util:properties id="commonProperties" location="classpath:common-default.properties"/>

The contents of the properties file contained:

hostUrl=localhost:8080

To use the value in the jsp, pull in the Spring tags by:

<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>

Tie it all together by

<spring:eval var="loginUrl" expression="@commonProperties.hostUrl"/>
<a href="http://${loginUrl}/hub/login.jsp">Return to login</a>

January 27th, 2014

Posted In: JSP, SpEl, Spring

2 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

LinkedIn Auto Publish Powered By : XYZScripts.com