Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring mvc 在带有liferay选项卡的选项卡标题中使用空格_Spring Mvc_Tabs_Liferay_Portlet - Fatal编程技术网

Spring mvc 在带有liferay选项卡的选项卡标题中使用空格

Spring mvc 在带有liferay选项卡的选项卡标题中使用空格,spring-mvc,tabs,liferay,portlet,Spring Mvc,Tabs,Liferay,Portlet,我正在为Portlet和liferay选项卡使用SpringMVC。我在选项卡标题中添加空格时遇到问题。假设我想在JSP中定义如下内容: <liferay-ui:tabs names="Sample Tab 1, Sample Tab 2" refresh="false" value="${myControllerValue}" > <liferay-ui:section> <jsp:include page='/jsp/myPage1.jsp' flu

我正在为Portlet和liferay选项卡使用SpringMVC。我在选项卡标题中添加空格时遇到问题。假设我想在JSP中定义如下内容:

<liferay-ui:tabs
names="Sample Tab 1, Sample Tab 2"
refresh="false"
value="${myControllerValue}" 
>
<liferay-ui:section>
     <jsp:include page='/jsp/myPage1.jsp' flush="true"/> 
</liferay-ui:section>
<liferay-ui:section>
    <jsp:include page='/jsp/myPage2.jsp' flush="true"/> 
</liferay-ui:section>
</liferay-ui:tabs>
这会导致另一个问题,因为我需要用几种语言显示选项卡名称,所以我需要用语言环境语言传递我想要的选项卡以匹配jsp id。最好的做法是将标题从选项卡id中拆分,并使用tabValues参数,但不知道如何做

我读了一些关于重新定义语言-ext.properties的内容,但我只是导入了选项卡

<%@taglib prefix="liferay-ui"   uri="http://liferay.com/tld/ui" %>
这是我的portlet.xml文件:

<portlet-app
version="2.0"
xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd">
<portlet>
    <portlet-name>MyAPP</portlet-name>
    <display-name>MyAPP</display-name>
    <portlet-class>org.springframework.web.portlet.DispatcherPortlet</portlet-class>
    <init-param>
        <name>contextConfigLocation</name>
        <value>/WEB-INF/portlet/MyAPP-portlet.xml</value>
    </init-param>                       
    <expiration-cache>0</expiration-cache>
    <supports>
        <mime-type>text/html</mime-type>
        <portlet-mode>VIEW</portlet-mode>
    </supports>
    <supported-locale>gl_ES</supported-locale>
    <supported-locale>es_ES</supported-locale>
    <resource-bundle>messages</resource-bundle>

    <resource-bundle>content/Language</resource-bundle>  

    <portlet-info>
        <title>MyAPP</title>
        <short-title>MyAPP</short-title>
        <keywords>MyAPP</keywords>
    </portlet-info>
</portlet>
</portlet-app>

MyAPP
MyAPP
org.springframework.web.portlet.DispatcherPortlet
上下文配置位置
/WEB-INF/portlet/MyAPP-portlet.xml
0
文本/html
看法
格拉斯
是的
信息
内容/语言
MyAPP
MyAPP
MyAPP

您可以使用
Language.properties
在选项卡中获得所需的确切标题名

中,您可以有:

<liferay-ui:tabs
    names="sample-tab-1, sample-tab-2"
    refresh="false"
    value="${myControllerValue}" 
>
您可以将
portlet.xml
中的
Language.properties
文件定义为:

<portlet>
    ...
    ...
    <resource-bundle>content/Language</resource-bundle>
    ...
</portlet>
因此,在控制器中,您将使用:

if(whatever){
   renderrequest.setAttribute("myControllerValue", "sample-tab-1");
}

更多信息。

您尝试过这种方法吗?我已经使用liferay Language.properties的钩子修复了我的问题,但如果这样做有效,它似乎是一个更简单的解决方案。我已经试着按照你说的做了,但是我甚至不能部署我的portlet(注意,我已经在我的portlet中定义了一些用于语言管理的属性)。此外,我仍然不知道liferay选项卡如何知道这些文件的位置,并使用它来代替liferay选项卡…@elcadro
content/Language
足以让容器知道从何处获取portlet的键值。我们使用这种方式来存储are语言文件,如果您看到市场上的liferay插件Portlet,您就会知道liferay也使用同样的方式进行国际化。好的,太好了。问题是,正如我告诉你的,我正试图让它成为你的方式,但我有一些部署错误(我编辑了我的问题,以便你可以看到它)。所以,这对我根本不起作用。无论如何,非常感谢…@elcadro一个
元素中不能有两个
元素。通过指向liferay开发指南的链接编辑了我的答案。您只需将选项卡标题的键放在
message.properties
文件中,就可以了。文件名不必是Language.properties,它可以是
资源包
元素中提供的任何文件名。只有一个问题:您是覆盖了liferay的jsp还是开发了自己的带有选项卡的jsp?
sample-tab-1=Sample Tab 1
sample-tab-2=Sample Tab 2
<portlet>
    ...
    ...
    <resource-bundle>content/Language</resource-bundle>
    ...
</portlet>
docroot
  |
  |--> src
        |
        |--> content
                |--> Language.properties
                |--> Language_en.properties
                |--> Language_ja.properties
                |--> Language_de.properties
                     ...
if(whatever){
   renderrequest.setAttribute("myControllerValue", "sample-tab-1");
}