public void doFilter(RenderRequest request, RenderResponse response, FilterChain chain) throws IOException, PortletException
{
String account = request.getPreferences().getValue("account", null);
if (account!=null) {
Element jQuery1 = response.createElement("script");
jQuery1.setAttribute("type", "text/javascript");
String textContent = "var _gaq = _gaq || [];\n" +
" _gaq.push(['_setAccount', '"+account+"']);\n" +
" _gaq.push(['_trackPageview']);\n" +
"\n" +
" (function() {\n" +
" var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\n" +
" ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';\n" +
" var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\n" +
" })();";
jQuery1.setTextContent(textContent);
response.addProperty(MimeResponse.MARKUP_HEAD_ELEMENT, jQuery1);
}
//
chain.doFilter(request, response);
}
ResponseFilter.java 文件源码
java
阅读 21
收藏 0
点赞 0
评论 0
项目:portlet-pack
作者:
评论列表
文章目录