【问题标题】:How to debug error "No render mappings found for MVC render command name"如何调试错误“未找到 MVC 渲染命令名称的渲染映射”
【发布时间】:2022-10-21 04:14:35
【问题描述】:

我正在为我的 Liferay DXP 开发一个模块,我正在努力调用我的 renderCommands。

在初始渲染时以及每当我尝试单击指向我的 RenderCommand 的链接时都会出现以下错误消息:

未找到 MVC 渲染命令名称的渲染映射 Portlet 的“/document-management/document/edit” com_company_tools_manager_documents_web_portlet_DocumentsPortlet

我有我的“view.jsp”,其中包含我的“init.jsp”、renderURL 的创建和链接:

<%@ include file="./init.jsp" %>
    
    <portlet:renderURL var="editDocumentURL">
        <portlet:param name="mvcRenderCommandName" value="<%=MVCCommandNames.EDIT_DOCUMENT %>" ></portlet:param>
    </portlet:renderURL>
    
<a href="${ editDocumentURL }">edit documents</a>

“MVCCommandNames.EDIT_DOCUMENT”指的是 MVCCommandNames.java:

package com.company.tools.manager.documents.web.constants;

public class MVCCommandNames {
    public static final String EDIT_DOCUMENT= "/document-management/document/edit"; }

我将文件包含在“init.jsp”中,如下所示:

<%@ page
    import="com.company.tools.manager.documents.web.constants.MVCCommandNames"%>

最后,我有这个“EditDocumentMVCRenderCommand.java”,它应该被视为一个组件并连接到链接:

package com.company.tools.manager.documents.web.portlet.action;
import com.company.tools.manager.documents.web.constants.DocumentsPortletKeys;
import com.company.tools.manager.documents.web.constants.MVCCommandNames;
import com.liferay.portal.kernel.portlet.bridges.mvc.MVCRenderCommand;
import org.osgi.service.component.annotations.Component;

@Component(immediate = true, property = { "javax.portlet.name=" + DocumentsPortletKeys.DOCUMENTS,
        "mvc.command.name=" + MVCCommandNames.EDIT_DOCUMENT}, service = MVCRenderCommand.class)
public class EditDocumentMVCRenderCommand implements MVCRenderCommand { (...) }

“DocumentsPortletKeys.DOCUMENTS”调用的 portlet 名称定义为

package com.company.tools.manager.documents.web.constants;

public class DocumentsPortletKeys {

    public static final String DOCUMENTS= "com_company_tools_manager_documents_web_portlet_DocumentsPortlet";
}

我忘了连接一些东西吗?如何找出“EditDocumentMVCRenderCommand.java”监听的 URL? 关于如何解决这个问题的任何其他建议?

问候

【问题讨论】:

    标签: java liferay portlet


    【解决方案1】:

    我遇到了同样的问题,并通过仅使用最少的代码(仅包括您在本文中共享的文件)创建一个新的 mvc 模块来解决它,并尝试专注于使渲染映射工作。 此外,如果您可以共享您的 DocumentsPortlet.java 来验证“javax.portlet.name”属性是否正确。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-10-05
      • 2023-03-21
      • 1970-01-01
      • 1970-01-01
      • 2013-11-15
      • 2020-12-09
      • 1970-01-01
      相关资源
      最近更新 更多