mardi 3 octobre 2017

How do I read a value from a properties file in a JSP for a Jersey-Spring application

I have a Jersey-Spring Application with a .jsp file I am trying to read the values from the Properties file using spring:eval but it has not value on JSP load Here is the eval used:

<spring:eval
expression="@appProperties.getProperty('ui.server.endpoint')"
var="serverEndpoint" />

Following is the web.xml file

<!DOCTYPE web-app PUBLIC
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://ift.tt/HeF78r" >

<web-app>
<display-name>cluui</display-name>
<servlet>
<servlet-name>RESTful Jersey Hello World Service</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-
class>
<init-param>
    <param-name>jersey.config.server.provider.packages</param-name>
    <param-value>com.cl.connect</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>RESTful Jersey Hello World Service</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
<!--servlet>
<servlet-name>spring-dispatcher</servlet-name>
<servlet-
 class>org.springframework.web.servlet.DispatcherServlet</servlet-
 class>
  <init-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>/WEB-INF/applicationContext.xml</param-value>
  </init-param>
<load-on-startup>2</load-on-startup>
</servlet-->
<listener>
<listener-
 class>org.springframework.web.context.ContextLoaderListener</listener-
  class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>

And following is the applicationContext.xml

<context:component-scan base-package="com.comcast.clu" />
<bean id="propertyConfigurer"class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="ignoreUnresolvablePlaceholders" value="true" />
    <property name="ignoreResourceNotFound" value="true" />
    <property name="properties" ref="appProperties" />
</bean>

<bean id="appProperties" 
class="org.springframework.beans.factory.config.PropertiesFactoryBean">
    <property name="ignoreResourceNotFound" value="true" />
    <property name="location" value="classpath:common.properties">
    </property>
</bean>

I dont have a Controller class though, is it always required even for a Jersey_Spring app? I have another Jersey-Spring app someone else wrote and that one does not have a Controller but the spring:eval works there

What is it that I am missing?




Aucun commentaire:

Enregistrer un commentaire