首先在配置文件中加入
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+"/";
%> 找了好多网站才找到这个办法记录下~!
本文介绍了一种在Freemarker模板引擎中设置路径的方法,通过在配置文件中添加特定参数,可以在模板文件中轻松获取上下文路径。


被折叠的 条评论
为什么被折叠?



