138-bathPath的作用?

在html中他的根路径/代表的是localhost:8080,并没有项目名。
假使我们不配置basePath,也没有/,则页面的跳转路径是按照相对路径来算的
/没有项目名的主要是解决我们项目名经常变化的问题

thymeleaf中的/自动加上了项目名,这一点和普通的html是不一样的。

<%
String basePath=request.getScheme()+"://"+request.getServerName()+":"+request.getLocalPort()+request.getContextPath()+"/";
%>
<html> <head> <base href="<%=basePath%>"> //因为这个标签后,就没有绝对路径了

  <script type="text/javascript">
   $(function(){
//给"创建"按钮添加单击事件
$("#createTranBtn").click(function () {
window.location.href="workbench/transaction/toSave.do";
});

});

</script>

</head>
原文地址:https://www.cnblogs.com/pogusanqian/p/12751315.html