在hybris

时间:2017-09-14 13:52:23

标签: java spring jsp spring-mvc hybris

我的project.properties中有一个键为userKey=value

我想在java中使用configservice读取jsp中的值。是否有可能这样做?

我尝试使用

<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<spring:message code="label.username"/>
<spring:message code="label.password"/>

但失败了以下错误:

  

WARN [hybrisHTTP30] [DefaultCMSComponentRendererRegistry]错误   处理组件标签。 currentComponent   [MerchGenericMediaComponentModel(8800615040060 @ 15)]例外:   javax.serv       2017年9月14日下午2:31:16 org.apache.catalina.core.ApplicationDispatcher调用       严重:Servlet jsp的Servlet.service()引发了异常       javax.servlet.jsp.JspTagException:在代码'userKey'下找不到locale'en'的消息。               在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)               在org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)               在javax.servlet.http.HttpServlet.service(HttpServlet.java:731)               在org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:439)               在org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)               在org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)               在javax.servlet.http.HttpServlet.service(HttpServlet.java:731)               在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)               在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)               在org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:747)               at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:603)              在org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:542)               在org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:160)               在org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303)               在org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1257)               在org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1037)               在org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:980)               在org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)               在org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)

3 个答案:

答案 0 :(得分:3)

这会奏效。使用Jsp中的以下代码段并替换&#39;属性键&#39;与您要从local.propertiesproject.properties

中检索的那个
${jalosession.tenant.config.getParameter('propertykey')}

答案 1 :(得分:2)

如果你真的只想设置一些语言属性,你应该明确地使用:

\web\webroot\WEB-INF\messages\base.properties

用于此配置。因此这个文件成了。但是,如果您要在* .jsp文件中使用其他属性,则可以使用:

<spring:eval expression="T(de.hybris.platform.util.Config).getParameter('your.code')" var="myVar" scope="page" />

答案 2 :(得分:1)

您应该尝试在 base.properties 文件(或 base_en)中添加标签(在本例中为 userKey = value )。属性)而不是 project.properties

base.properties 用于I18n,而

project.properties 用于配置端口,构建环境,JVM选项等...