request 获取服务根目录地址

来源:互联网 发布:超星网络课答案 编辑:程序博客网 时间:2024/06/05 15:16

http://www.cnblogs.com/zhongzheng123/p/5702293.html


这是常用的request获取服务地址的常用方式。

源请求服务地址:http://localhost/api-server/1/forum/thread/hot_topic?sex=1

String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

这个截取结果:http://localhost:80/api-server/


原创粉丝点击