一次笔记--springMVC+Velocity
来源:互联网 发布:javascript 子元素 编辑:程序博客网 时间:2024/06/07 22:59
1.部分关于Velocity的配置
spring-mvc.xml
<!-- Velocity视图解析器 默认视图 --><bean id="velocityViewResolver" class="org.springframework.web.servlet.view.velocity.VelocityViewResolver"><property name="contentType" value="text/html;charset=UTF-8" /><property name="viewNames" value="*.html" /> <property name="suffix" value=""/> <property name="dateToolAttribute" value="date" /> <property name="numberToolAttribute" value="number" /> <property name="toolboxConfigLocation" value="/WEB-INF/velocity-toolbox.xml" /> <property name="requestContextAttribute" value="rc"/> <property name="order" value="0"/></bean><bean id="velocityConfigurer" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer"> <property name="resourceLoaderPath" value="/,/WEB-INF/page" /> <property name="velocityProperties"> <props> <prop key="input.encoding">UTF-8</prop> <prop key="output.encoding">UTF-8</prop> <prop key="contentType">text/html;charset=UTF-8</prop> </props> </property></bean>
velocity-toolbox.xml
<?xml version="1.0" encoding="UTF-8" ?><toolbox><!-- velocity 自定义标签 --><tool> <key>shiro</key> <scope>application</scope> <class>com.ylz.VelocityShiro</class></tool><data type="String"><key>WebsiteVersion</key><value>Version 2.0.0</value></data></toolbox>配置重点:resourceLoaderPath,模板放置路径(个人理解,模板将处理此路径下的对应的文件可以是 html 也可以是其他)
2.注意要点
Velocity解析 Controller 层返回的数据来调用页面
所以需要 写 Controller
@Controllerpublic class SysPageController {@RequestMapping("{url}.html")public String goToHtml(@PathVariable("url") String url){return url + ".html";}}
spring mvc中的@PathVariable是用来获得请求url中的动态参数的例如:
@RequestMapping("page/{url}.html")public String generator(@PathVariable("url") String url){return "page/" + url + ".html";}
阅读全文
0 0
- 一次笔记--springMVC+Velocity
- 小白零xml搭建springmvc+Velocity+mybatis之笔记
- velocity笔记
- velocity笔记
- velocity笔记
- Velocity笔记
- Velocity笔记
- springMVC+velocity配置
- springmvc velocity 配置
- springMVC整合velocity框架
- springMVC整合velocity框架
- velocity整合springMVC
- SpringMVC+Velocity整合配置
- springMVC+velocity配置
- springmvc+mybatis+velocity配置
- SpringMVC整合Velocity要点
- springMVC + velocity 的结合
- springMVC 整合Velocity
- Linux安装软件
- python 学习与复习 1
- 关于避免按钮短时间内频繁点击或过快点击的处理方法
- Android 7.0 行为变更 通过FileProvider在应用间共享文件吧
- js缓存
- 一次笔记--springMVC+Velocity
- 程序注释
- 判断cron表达式输入是否有效的正则表达式
- 犯错会让你成为一个更好的链接构建者
- 折半查找以及插入
- HTML5 侧拉实现
- opencv-鼠标作为油漆刷
- 二维码扫码优化
- NX10.0 UGOPEN与VS2017配置