jsp - Liferay:创建一个 portlet 配置页面。如何提供正确的jsp路径?

标签 jsp liferay liferay-6 portlet spring-portlet-mvc

我想为 liferay portlet 创建一个配置页面。

来自 portlet.xml 的一些代码

<portlet-name>example-config</portlet-name>
    <display-name>example-to-delete</display-name>
    <portlet-class>org.springframework.web.portlet.DispatcherPortlet</portlet-class>
    <init-param>
        <name>contextConfigLocation</name>
        <value>/WEB-INF/spring-context/portlet/example-config-portlet.xml</value>
    </init-param>
    <init-param>
        <name>config-jsp</name>
        <value>/WEB-INF/html/jsp/config.jsp</value>
    </init-param>

配置ActionImpl
public class ConfigurationActionImpl implements ConfigurationAction {

@Override
public void processAction(PortletConfig portletConfig, ActionRequest actionRequest,
                          ActionResponse actionResponse) throws Exception {

}

@Override
public String render(PortletConfig portletConfig, RenderRequest renderRequest,
                     RenderResponse renderResponse) throws Exception {
    System.out.println("RENDER CALL");
    return "/html/jsp/config.jsp";
}
}

liferay-portlet.xml
<portlet>
    <portlet-name>example-to-delete</portlet-name>
    <icon>/icon.png</icon>
    <configuration-action-class>by.example.ConfigurationActionImpl</configuration-action-class>
    <instanceable>false</instanceable>      
</portlet>

当我运行它时,我在配置选项中有一个选项卡(渲染方法有效,我在控制台中看到消息“RENDER CALL”),但我的 jsp 没有显示,没有错误和警告。我尝试了不同的方法来提供 jsp 路径,但没有进展。我该怎么办?

最佳答案

如果配置操作类扩展 DefaultConfigurationAction ,将 JSP 路径指定为 portlet.xml 中的 init 参数就足够了(configTemplateconfig-jsp 是同样有效的名称)。您不必覆盖 render方法。

在您的情况下,配置操作类不扩展 DefaultConfigurationAction ,所以 init 参数是没用的。

JSP 路径必须始终从类路径根目录开始 - 即。从 /WEB-INF 开始对于放置在那里的 JSP。

Developer's Guide有关 portlet 配置的完整描述。

您还可以使用 Spring Portlet MVC 框架(如问题所示使用)开发可配置的 portlet。这意味着要为编辑 portlet 模式 (@Controller @RequestMapping("edit")) 创建一个专用 Controller 。使用 Spring,您可以以与 portlet View 模式相同的方式实现配置(即使用相同的 JSP 标记、表单绑定(bind)、验证以及 Spring 框架带来的所有舒适性)。

关于jsp - Liferay:创建一个 portlet 配置页面。如何提供正确的jsp路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33170762/

相关文章:

java - Liferay LDAP 身份验证未按预期工作

java - GSON从复杂的json中获取字符串

javascript - 如果脚本文件放置在外部,则无法获取 ${findState} 值

gradle - Unresolved requiremnet:导入包:com.google.api.client.auth.client.auth.oauth2;版本= {1.30.0,2.0.0}

liferay - 获取用户特定的网页内容

liferay - 为什么 JRE 与 Liferay

sql - 如何通过自定义插件portlet中的custom-finder获取liferay实体?

java - 使用户无法访问网页

jsp - 如何使用 Jetty 提供 JSP 文件?

liferay - 以编程方式更改文档库文档文件条目类型