Reputation: 33
I have a key in my project.properties as userKey=value
I wanna read the value in jsp with using configservice in java. Is there a possibility to do it?
I tried to use
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<spring:message code="label.username"/>
<spring:message code="label.password"/>
but it failed with below error :
WARN [hybrisHTTP30] [DefaultCMSComponentRendererRegistry] Error processing component tag. currentComponent [MerchGenericMediaComponentModel (8800615040060@15)] exception: javax.serv Sep 14, 2017 2:31:16 PM org.apache.catalina.core.ApplicationDispatcher invoke SEVERE: Servlet.service() for servlet jsp threw exception javax.servlet.jsp.JspTagException: No message found under code 'userKey' for locale 'en'. at org.springframework.web.servlet.tags.MessageTag.doEndTag(MessageTag.java:200) at org.apache.jsp.WEB_002dINF.views.mobile.cms.th.merchgenericmediacomponent_jsp._jspx_meth_spring_005fmessage_005f0(merchgenericmediacomponent_jsp.java:472) at org.apache.jsp.WEB_002dINF.views.mobile.cms.th.merchgenericmediacomponent_jsp._jspService(merchgenericmediacomponent_jsp.java:130) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:731) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:439) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339) at javax.servlet.http.HttpServlet.service(HttpServlet.java:731) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:747) at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:603) at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:542) at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:160) at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303) at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1257) at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1037) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:980) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
Upvotes: 3
Views: 3829
Reputation: 66
This will work. Use the below snippet in the Jsp
and replace the 'propertykey' with the one which you want to retrieve from local.properties
or project.properties
.
${jalosession.tenant.config.getParameter('propertykey')}
Upvotes: 5
Reputation: 1168
If you really only want to set some language properties than you should definitly use the:
\web\webroot\WEB-INF\messages\base.properties
for this configuration. Therefore this file was made. But if you have some other properties that you want to use in you *.jsp file you can use:
<spring:eval expression="T(de.hybris.platform.util.Config).getParameter('your.code')" var="myVar" scope="page" />
Upvotes: 4
Reputation: 1593
You should try putting your labels(in this case userKey=value) in base.properties file (or base_en.properties) instead of project.properties
base.properties is used for I18n, while
project.properties is used to configure ports, build environment, JVM options, etc...
Upvotes: 1