项目随笔之springmvc中freemark如何获取项目路径
转载:http://blog.csdn.net/whatlookingfor/article/details/51538995
在SpringMVC框架中使用Freemarker试图时,要获取根路径的方式如下:
<!-- FreeMarker视图解析 如返回userinfo。。在这里配置后缀名ftl和视图解析器。。 -->
<bean id="viewResolverFtl"
class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.freemarker.FreeMarkerView" />
<property name="suffix" value=".ftl" />
<property name="contentType" value="text/html;charset=UTF-8" />
<property name="exposeRequestAttributes" value="true" />
<property name="exposeSessionAttributes" value="true" />
<property name="exposeSpringMacroHelpers" value="true" />
<property name="requestContextAttribute" value="request" />
<property name="cache" value="true" />
<property name="order" value="0" />
</bean>
其中property name=”requestContextAttribute” value=”request”是关键。
意思是把Spring的RequestContext对象暴露为变量request
利用${request.contextPath}来获取应用程序的contextPath
项目随笔之springmvc中freemark如何获取项目路径的更多相关文章
- springMvc中restful风格的api路径中把小数点当参数,SpringMvc中url有小数点
在springMvc web项目中restful风格的api路径中有小数点会被过滤后台拿不到最后一个小数点的问题, 有两种解决方案: 1:在api路径中加入:.+ @RequestMapping(&q ...
- Android无法导入下载好的项目(和Eclipse中已经存在的项目命名一样导致冲突)解决办法
错误提示: 在我们到导入从网络下载的项目时,经常会出现如下问题(选择的项目变灰,并且提示要选择至少一个项目): 错误原因: 出现这样的错误主要是因为你的Eclipse已经存在了和上图中New Proj ...
- java(JSP)中几种获取项目路径方式
在jsp和class文件中调用的相对路径不同. 在jsp里,根目录是WebRoot 在class文件中,根目录是WebRoot/WEB-INF/classes 当然你也可以用System.getPro ...
- 161018、springMVC中普通类获取注解service方法
1.新建一个类SpringBeanFactoryUtils 实现 ApplicationContextAware package com.loiot.baqi.utils; import org.sp ...
- java中几种获取项目路径方式
转自http://caodaoxi.iteye.com/blog/1234805 在jsp和class文件中调用的相对路径不同. 在jsp里,根目录是WebRoot 在class文件中,根目录 ...
- 在springmvc中使用requestContextListener获取全部的request对象
RequestContextListener实现了 ServletRequestListener ,在其覆盖的requestInitialized(ServletRequestEvent reques ...
- springMVC 中几种获取request和response的方式
1.最简单方式:参数 例如: @RequestMapping("/test") @ResponseBody public void saveTest(HttpServletRequ ...
- java web项目导入到eclipse中变成了java项目的一种情况的解决办法
前提,我把代码上传到github上之后,在另外一台电脑上拉下之后,先报出现的是jre不对,然后换成了当前的jre,然后红色的感叹号消失了但是之前项目上那个小地球不见了,也就是说变成了java项目. - ...
- myeclipse中的web项目导入到eclipse中注意事项,项目部署到tomcat后无法访问jsp文件
打开eclipse,点击空白处,右键可以看到import>general>existing projects into workspace>next>选择你的myeclipse ...
随机推荐
- 编写输出Hellow word!
打开java运行环境(eclipse),然后输入以下语句,点击编译运行后即可输出“Hello World,”. public class HelloWorld { public static void ...
- python-写入csv 文件
项目要做一个导出客户信息的功能,需要写入csv: 注意文件写入的方式 例如 write open(‘w’) 从头开始写,之前写的会被替换 write open(‘a’) 则代表追加,文件指针放 ...
- TCriticalSection(Delphi)
临界区对象TCriticalSection(Delphi) 与 TRtlCriticalSection 的区别 临界区对象TCriticalSection(Delphi) 与 TRtlCritical ...
- FZU - 2062 - Suneast & Yayamao
先上题目: Problem 2062 Suneast & Yayamao Accept: 146 Submit: 319Time Limit: 1000 mSec Memory L ...
- mongodb--reduce并行处理框架
reduce 命令 db.runCommand( { mapReduce: <collection>, map: <function>, reduce: <functio ...
- [bzoj1708][Usaco2007 Oct]Money奶牛的硬币_动态规划_背包dp
Money奶牛的硬币 bzoj-1708 Usaco-2007 Oct 题目大意:在创立了她们自己的政权之后,奶牛们决定推广新的货币系统.在强烈的叛逆心理的驱使下,她们准备使用奇怪的面值.在传统的货币 ...
- Delicious Apples (hdu 5303 贪心+枚举)
Delicious Apples Time Limit: 5000/3000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Other ...
- 一个使用命令行编译Android项目的工具类
一个使用命令行编译Android项目的工具类 简单介绍 编译apk项目须要使用的几个工具,基本都在sdk中,它们各自是(Windows系统): 1.aapt.exe 资源打包工具 2.android. ...
- 创建MAVEN项目报错
创建MAVEN项目pom.xml报错 Failure to transfer org.apache.maven:maven-archiver:jar:2.4.2 from http://repo.ma ...
- 远程桌面授权server没有提供许可证问题解决方法
今天远程server报如图所看到的错误,网上查找的方法 方法一:(亲測有效) mstsc /V:192.168.0.3 /admin 方法二:(因为server正在使用中,未作測试) 删除远程桌面服 ...