繁体   English   中英

Liferay:在一个liferay插件项目中配置多个Spring MVC Portlet

[英]Liferay : Configuring Multiple Spring MVC Portlets in one liferay plugin project

我正在用liferay开发基于Spring MVC的portlet。 基本上,我想在一个liferay项目本身中配置和维护2或3个portlet。 能否在某些方面指导我进行相同的配置。 类似于portlet.xml的配置代码,spring config和web config(如果需要)。 我只需要分别为我的所有portlet配置一个默认控制器,这样每个portlet就会进入不同的登录页面。

有人知道如何配置这些portlet吗? 任何建议都会有所帮助:D

提前致谢。

是的,可以在单个插件项目中配置多个spring portlet,以使单个.war文件包含多个portlet。

在web.xml中

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:applicationContext.xml</param-value>
</context-param>
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<servlet>
    <servlet-name>view-servlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.ViewRendererServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>view-servlet</servlet-name>
    <url-pattern>/WEB-INF/servlet/view</url-pattern>
</servlet-mapping>

在applicationContext.xml中

您可以在此处为所有portlet指定通用bean配置。

<context:annotation-config />
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver" >
    <property name="cache" value="false"/>
    <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
    <property name="prefix" value="/jsp/"/>
    <property name="suffix" value=".jsp"/>
    <property name="contentType" value="text/html; charset=UTF-8" />
</bean>

在portlet.xml中

您可以在此文件中指定<portlet>的多个条目。 对于spring portlet,应按如下所示指定<portlet-class>和<init-param>。

    <portlet-class>org.springframework.web.portlet.DispatcherPortlet</portlet-class>
    <init-param>
        <name>contextConfigLocation</name>
        <value>classpath:myportlet-context.xml</value>
    </init-param>

在myportlet-context.xml中

将您的portlet控制器类放在my.portlet.package中,并在此文件中指定它。

<context:component-scan base-package =“ my.portlet.package” />

在liferay-portlet.xml中

即使此文件也包含多个<portlet>标记。

在您的portlet控制器类中

添加注释以指定控制器并以portlet模式进行映射。 您可以在此处查看Spring文档中提供的各种其他映射。

@Controller

@RequestMapping(值= PortletModeVal.VIEW)

公共类MyPortletControll实现PortletConfigAware

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM