url-rewriting - 向 liferay 上的博客文章页面添加扩展

标签 url-rewriting liferay blogs liferay-6

我的问题是我想在我的每一篇博客文章中添加“.html”扩展名。例如,现在我有一篇博客文章网址'http://www.indu.com/blog/-/blogs/creating-a-custom-portlet-in-liferay '我想要的是'http://www.indu.com/blog/-/blogs/creating-a-custom-portlet-in-liferay.html '

如果有人能提供帮助,我将不胜感激?

最佳答案

我想知道你为什么想要这个。

无论如何,我认为您可以更改 BlogsEntryurlTitle 字段并将 .html 附加到字符串。每当创建或更新博客时,可以使用 service-wrapper-hook 将 .html 附加到 urlTitle

或者,您甚至可以使用 ModelListener(如果 BlogsEntry Hook 存在),通过使用 onCreateonUpdate 更新博客的 urlTitle 方法。

编辑

urlTitle 字段存在于 BlogsEntry 表中。

您可以使用以下方法在 java 中访问它:

BlogsEntry blog = BlogsEntryLocalServiceUtil.getBlogsEntry(90989); // retrieves the blog-entry

String blogUrlTitle = blog.getUrlTitle(); 

blog.setUrlTitle(blogUrlTitle + ".html"); // this would set the string

您可以检查 blogUrlTitle,这样就不会在字符串中附加重复的 .html:

if (!blogUrlTitle.contains(".html")) { // append only if the title does not contain `.html`
    blog.setUrlTitle(blogUrlTitle + ".html");
}

您可以根据需要改进代码,以上只是一个指导方针。

作为旁注,我总是会尝试与客户推理为什么他们想要某些东西,这不仅有助于抵御不良的更改请求,而且还有助于为客户提供替代方案(这是更少的)对像我们这样的开发商征税;-))。在大多数情况下,这有助于更好地了解客户的业务并提供更好的返回。

关于url-rewriting - 向 liferay 上的博客文章页面添加扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14869377/

相关文章:

css - 为什么使用hexo发布博客无法加载js和css

javascript - 如何将 Youtube 视频图像添加到博客?

tomcat - 在tomcat中重写url而不使用第三方api

.htaccess - 自定义 404 错误页面问题

java - 在Liferay 6.1 SDK中使用ant构建时发生内部编译器错误

Liferay 和内容安全策略

mysql - Liferay 6.2 + MySQL "Database connection could not be established. Please check your connection settings."

php - 如何实现博客文章的正文以获得换行符

.htaccess - htaccess - 检查文件是否存在,否则运行 php

regex - IIS7 的 URL 重写模块中的正则表达式