java – liferay 6.1中的友好URL
作者:互联网
我刚刚将博客(默认)portlet的URL更改为“http:// localhost:8080 / web / standorman / blogs / – / blogs / application-development-in-liferay”
但我希望它是“http:// localhost:8080 / web / standorman / blogs / application-development-in-liferay”
谁能建议我怎么解决?
解决方法:
首先,你不能摆脱/ – /没有真正侵入你不想做的Liferay(它将导致更多问题而不是好处).所有你可以摆脱的是一个“博客”,以URL / web / standorman / – / blogs / application-development-in-liferay结尾 – 这对我来说似乎足够接近.
以下是如何使用yannicuLar建议的https://github.com/DevJonny/Liferay-6-Friendlier-Friendly-URL-Mapper/来做到这一点.
他的建议对你不起作用,因为你试图改变Liferay本身嵌入的开箱即用的Liferay portlet.要改变那些必须使用EXT插件的东西.所以这正是你应该做的.
第1步 – 在Plugins SDK中创建一个EXT插件(通过在插件SDK“ext”子文件夹中运行create.bat或create.sh).
第2步 – 进入创建的ext插件文件夹,在/ docroot / WEB-INF / ext-impl / src中删除文件portal-ext.properties,然后将此文件–https://github.com/DevJonny/Liferay-6-Friendlier-Friendly-URL-Mapper/blob/master/docroot/WEB-INF/src/com/mysmallcornerstudios/friendlierurlmapping/portlet/FriendlierFriendlyURLMapper.java放入其中以使其在路径中
/docroot/WEB-INF/ext-impl/src/com/mysmallcornerstudios/friendlierurlmapping/portlet/FriendlierFriendlyURLMappe r.java
第3步 – 打开文件docroot / WEB-INF / ext-web / docroot / WEB-INF / liferay-portlet-ext.xml
用这样的内容填充:
<?xml version="1.0"?>
<!DOCTYPE liferay-portlet-app PUBLIC "-//Liferay//DTD Portlet Application 6.1.0//EN" "http://www.liferay.com/dtd/liferay-portlet-app_6_1_0.dtd">
<liferay-portlet-app>
<portlet>
<portlet-name>33</portlet-name>
<icon>/html/icons/blogs.png</icon>
<struts-path>blogs</struts-path>
<configuration-action-class>com.liferay.portlet.blogs.action.ConfigurationActionImpl</configuration-action-class>
<indexer-class>com.liferay.portlet.blogs.util.BlogsIndexer</indexer-class>
<open-search-class>com.liferay.portlet.blogs.util.BlogsOpenSearchImpl</open-search-class>
<scheduler-entry>
<scheduler-event-listener-class>com.liferay.portlet.blogs.messaging.CheckEntryMessageListener</scheduler-event-listener-class>
<trigger>
<simple>
<property-key>blogs.entry.check.interval</property-key>
<time-unit>minute</time-unit>
</simple>
</trigger>
</scheduler-entry>
<scheduler-entry>
<scheduler-event-listener-class>com.liferay.portlet.blogs.messaging.LinkbackMessageListener</scheduler-event-listener-class>
<trigger>
<simple>
<property-key>blogs.linkback.job.interval</property-key>
<time-unit>minute</time-unit>
</simple>
</trigger>
</scheduler-entry>
<friendly-url-mapper-class>com.mysmallcornerstudios.friendlierurlmapping.portlet.FriendlierFriendlyURLMapper</friendly-url-mapper-class>
<friendly-url-mapping>blogs</friendly-url-mapping>
<friendly-url-routes>com/liferay/portlet/blogs/blogs-friendly-url-routes.xml</friendly-url-routes>
<preferences-unique-per-layout>false</preferences-unique-per-layout>
<preferences-owned-by-group>true</preferences-owned-by-group>
<use-default-template>false</use-default-template>
<scopeable>true</scopeable>
<private-request-attributes>false</private-request-attributes>
<private-session-attributes>false</private-session-attributes>
<render-weight>50</render-weight>
<header-portlet-css>/html/portlet/blogs/css/main.css</header-portlet-css>
<css-class-wrapper>portlet-blogs</css-class-wrapper>
<add-default-resource>true</add-default-resource>
</portlet>
</liferay-portlet-app>
这个内容对于我的Liferay版本是正确的.对于您的版本,您可能需要执行此操作以生成类似的内容:
>在你的Liferay发行版中找到文件liferay-portlet.xml(应该在webapps / ROOT / WEB-INF中用于Tomcat捆绑的发行版,但可能在不同的位置用于其他遇险 – 只需搜索它)
>在该文件中找到< portlet> …< / portlet>具有< portlet-name> 33< / portlet-name>的部分在里面
>复制整个部分< liferay-portlet-app><! - 复制文本到这里 - >< / liferay-portlet-app>在EXT插件中提到上面的文件docroot / WEB-INF / ext-web / docroot / WEB-INF / liferay-portlet-ext.xml.
>替换行< friendly-url-mapper-class> …< / friendly-url-mapper-class>与< friendly-url-mapper-class> com.mysmallcornerstudios.friendlierurlmapping.portlet.FriendlierFriendlyURLMapper< / friendly-url-mapper-class>
>删除线条
“
<portlet-data-handler-class>com.liferay.portlet.blogs.lar.BlogsPortletDataHandlerImpl</portlet-data-handler-class>
<social-activity-interpreter-class>com.liferay.portlet.blogs.social.BlogsActivityInterpreter</social-activity-interpreter-class>
<xml-rpc-method-class>com.liferay.portlet.blogs.util.PingbackMethodImpl</xml-rpc-method-class>
<asset-renderer-factory>com.liferay.portlet.blogs.asset.BlogsEntryAssetRendererFactory</asset-renderer-factory>
<atom-collection-adapter>com.liferay.portlet.blogs.atom.BlogsEntryAtomCollectionAdapter</atom-collection-adapter>
<custom-attributes-display>com.liferay.portlet.blogs.BlogsEntryCustomAttributesDisplay</custom-attributes-display>
<workflow-handler>com.liferay.portlet.blogs.workflow.BlogsEntryWorkflowHandler</workflow-handler>
第4步 – 部署你的ext插件(在它的文件夹中运行ant来构建它,在Plugins SDK中找到子文件夹“dist”,找到你的插件的.war文件 – 通过将它复制到“部署”将该.war文件部署到Liferay中Liferay distrib内的文件夹)并重新启动Liferay.
应该这样做.
标签:java,url-rewriting,liferay-6,friendly-url 来源: https://codeday.me/bug/20190709/1411766.html