1.在当前JSP中的java代码中获取,再在JS中获取
2.在跳入当前页面的action中获取根路径,放入request中,再在JS中获取
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
request.setAttribute("basePath", basePath);
再在JS中通过EL表达式调用:
var basePath = ${'basePath'};
新手成长,如有不对,欢迎各位指教