freemarker request.contextPath

来源:互联网 发布:手机图书馆软件 编辑:程序博客网 时间:2024/06/13 02:12

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

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

exapmle:

<!DOCTYPE HTML>
<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>



0 0
原创粉丝点击