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
Liferay request current page name
提问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() 可能会导致不同的字符编码格式,请谨慎使用,可能会导致某些字符串函数失败

