For storing build numbers I think properties files is the best place. And for your problem, you can get this build number using Spring tag library which can be included like this,
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
Updated
You can then get the build number from properties file which is configured in your ApplicationServlet.xml and finally can use build number as follows,
<spring:message code="buildNumber" var="buildNumber" />
<link rel="stylesheet" href="<c:url value="/resources/css/custom/select2.css?${buildNumber}"/>" type="text/css" />
Your applicationServlet-servlet.xml file must include something like this,
<beans:bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<beans:property name="basenames">
<beans:list>
<beans:value>buildNumber</beans:value>
<beans:value>gui</beans:value>
<beans:value>message</beans:value>
</beans:list>
</beans:property>
</beans:bean>
Here you can store your build number in separate properties file named, buildNumber.properties and having entry like this, buildNumber=601.
You can change the build number anytime you want to deploy your latest code to the server.
With this you can ensure that your client won't need to clear his own browsers cache whenever a new version of your application has deployed.
<%= java.lang.Math.round(java.lang.Math.random() * 100) %>this it self?