SpringBoot 在FreeMaker中使用 request.contextPath

首先在配置文件中加入 

spring.freemarker.request-context-attribute=request

然后在模板文件中可以这样使用

var url='${request.contextPath}/public/wxmember/save';


这种使用方式就好像在jsp中这样

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


找了好多网站才找到这个办法记录下~!

猜你喜欢

转载自blog.csdn.net/winnershili/article/details/80420201