1
2
3
4
|
String path = request.getContextPath();
String basePath = request.getScheme() +
"://"
+ request.getServerName() +
":"
+ request.getServerPort()
+ path +
"/"
;
|
再在JS中调用:
1
2
|
var
basePath =
'<%=basePath%>'
;
alert(basePath);
//http://localhost:8080/
|