jsp之获取域名

*、jsp页面上通过request获取域名

    

String contextPath = request.getContextPath();  
StringBuffer url= request.getRequestURL();
String head=headerReferer.substring(0,url.indexOf(contextPath)+contextPath.length()+1);   
request.setAttribute("httpheadd",httpheadd);
httpheadd = 域名+程序的根名称+‘/’

     备注:通过上面一行可通过${httpheadd}使用获取的域名信息

                应用实例:http://www.cae.cn/cae/jsp/player/p_player.jsp?url=网络的绝对地址即可(在线播放)

猜你喜欢

转载自lbovinl.iteye.com/blog/2337397
今日推荐