freemarker request.contextPath

      class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver"
      p:prefix="/" p:suffix=".ftl">
   name="cache" value="false" />
   name="viewClass"
           value="org.springframework.web.servlet.view.freemarker.FreeMarkerView" />
   name="contentType" value="text/html;charset=UTF-8">
   name="exposeRequestAttributes" value="true" />
   name="exposeSessionAttributes" value="true" />
   name="exposeSpringMacroHelpers" value="true" />
   name="requestContextAttribute" value="request"/>
   name="order" value="0">

in this config, there is an properties named requestContextAttribute, we request as value, them we can get context Path through request Object.

exapmle:

< html >
< head >
<#assign ctx = request.contextPath />
< meta  http-equiv = "Content-Type"  content = "text/html; charset=utf-8;NO-CACHE"  />
< link  rel = "icon"  href = "${ctx!}/images/JASU_Squares_ J.jpg"   />
 
< link  type = "text/css"  rel = "stylesheet"  href = "${ctx}/css/show_list.css" />
< script  type = "text/javascript"  language = "javascript"  src = "${ctx}/js/jquery/jqueryui/jquery.ui.core.min.js" > script >
head >
<@pageOnloadJs />
<@body />
html >



你可能感兴趣的:(freemarker)