2

liferay で Spring MVC ベースのポートレットを開発しています。基本的に、1 つの liferay プロジェクト自体で 2 つまたは 3 つのポートレットを構成および維持したいと考えています。同じために必要な構成を案内してくれる人もいます。portlet.xml、Spring 構成、および Web 構成 (必要な場合) の構成コードと同様です。すべてのポートレットのデフォルト コントローラーを個別に構成して、それぞれが異なるランディング ページに表示されるようにするだけです。

これらのポートレットを構成する方法を知っている人はいますか? どんな提案も役に立ちます:D

前もって感謝します。

4

1 に答える 1

4

はい、単一の .war ファイルに複数のポートレットが含まれるように、単一のプラグイン プロジェクトで複数の Spring ポートレットを構成することは可能です。

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 内

ここで、すべてのポートレットの共通 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-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 内

ポートレット コントローラ クラスを my.portlet.package に配置し、このファイルで指定します。

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

liferay-portlet.xml 内

このファイルにも複数の <portlet> タグが含まれています。

ポートレット コントローラ クラス内

アノテーションを追加してコントローラーを指定し、ポートレット モードでマップします。春のドキュメントで利用可能な他のさまざまなマッピングをここで見ることができます。

@コントローラ

@RequestMapping(値 = PortletModeVal.VIEW)

パブリック クラス MyPortletControll は PortletConfigAware を実装します

于 2014-05-25T10:01:45.580 に答える