Message Boards

Liferay 7.3 - Spring MVC Portlet adds js/css resources twice

Sergey Shishov, modified 3 Years ago.

Liferay 7.3 - Spring MVC Portlet adds js/css resources twice

New Member Posts: 3 Join Date: 9/9/20 Recent Posts
Hello!
Liferay 7.3.0

When I use js/css resources in standard spring-mvc-portlet (from maven archetype) with liferay-portlet.xml
<portlet>
    ...
    <header-portlet-css>/css/main.css</header-portlet-css>
    ...
</portlet>

The resources adds at the page twice:
<link href="/o/jsp-spring-mvc-portlet/css/main.css?browserId=firefox&amp;themeId=classic_WAR_classictheme&amp;minifierType=css&amp;languageId=en_US&amp;b=7301&amp;t=1599805556000" rel="stylesheet" type="text/css">
<link href="/o/jsp-spring-mvc-portlet/css/main.css?browserId=firefox&amp;themeId=classic_WAR_classictheme&amp;minifierType=css&amp;languageId=en_US&amp;b=7301&amp;t=1599805556000" rel="stylesheet" type="text/css">
Similar behavior with native example on github: /liferay-blade-samples/tree/7.0/maven/apps/springmvc-portlet

But!

When I try use native example without spring - war-mvc-portlet (from maven archetype), it works correctly
<link href="/o/war-mvc-portlet/css/main.css?browserId=firefox&amp;themeId=classic_WAR_classictheme&amp;minifierType=css&amp;languageId=en_US&amp;b=7301&amp;t=1599824288000" rel="stylesheet" type="text/css">

Easy way - not to use <header-portlet-css> when using spring and add resources in portlet body. But...