java Liferay 请求当前页面名称

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1923459/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 18:32:22  来源:igfitidea点击:

Liferay request current page name

javaliferayportal

提问by layska

What is the smartest way to get current page name where request came from? By page I mean the real page name that contains current portlet.

获取请求来自的当前页面名称的最聪明方法是什么?我所说的页面是指包含当前 portlet 的真实页面名称。

回答by Awano

By using something like that you should be ok

通过使用类似的东西,你应该没问题

ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
String title = themeDisplay.getLayout().getName(themeDisplay.getLocale());

回答by Ziyi Wang

just be aware,themeDisplay.getLocale() could result different char encoding format, use with caution, may cause certain string functions to fail

请注意,themeDisplay.getLocale() 可能会导致不同的字符编码格式,请谨慎使用,可能会导致某些字符串函数失败