strust2和velocity的配置
来源:互联网 发布:知合控股 华夏幸福 编辑:程序博客网 时间:2024/05/17 23:11
搜索velocity,资料真是不多,网上很多strust2和velocity的配置是不正确的!搭个环境都费了好久时间,在此记录备忘
开始前加入必要jar,我这里加的有:commons-logging-1.0.4.jar,freemarker- 2.3.15.jar,ognl-2.7.3.jar,xwork-core-2.1.6.jar,struts2-core- 2.1.8.1.jar,commons-fileupload-1.2.1.jar,commons-collections- 3.2.jar,commons-lang-2.3.jar,commons-digester-2.0.jar,commons-beanutils- 1.7.0.jar,velocity-tools-1.4.jar,velocity-1.6.3.jar。
首先,web.xml文件,直接从下载的struts2压缩包中的blank项目中复制即可,无需其他多余配置
其次,struts.xml文件,先也从struts2的blank项目中复制一份,放到src目录下
再次,在WEB-INF下新建两个文件,velocity的配置velocity.properties和velocity tools的toolbox.xml(这两个文件的文件名随意)
第四,WEN-INF中新建一个VM_global_library.vm文件,内容为空
第五,在struts配置文件中加入下面两行,注意value的文件路径,就是第三步中新建的
<constant name="struts.velocity.toolboxlocation" value="WEB-INF/toolbox.xml" />
<constant name="struts.velocity.configfile" value="WEB-INF/velocity.properties" />
加入后:
<struts>
<constant name="struts.velocity.toolboxlocation" value="WEB-INF/toolbox.xml" />
<constant name="struts.velocity.configfile" value="WEB-INF/velocity.properties" />
<include file="struts-default.xml" />
<package name="default" extends="struts-default">
<action name="hello" class="test.Hello" method="execute">
<result name="success">hello.vm</result>
</action>
</package>
</struts>
第六,编码问题,统一编码,将所有文件的编码都给为同一种,如utf-8,同时在.vm文件中加上<meta http-equiv="content-type" content="text/html;charset=UTF-8" />,还要更改服务器的配置(如tomcat,打开tomcat conf目录下server.xml,找到你使用的Connector,不知道用哪个就改所有的Connector,在这个标签的最后加上 URIEncoding="UTF-8"(要跟前面一致))这样基本可以解决乱码问题
最后,写自己的.vm尝试尝试吧
开始前加入必要jar,我这里加的有:commons-logging-1.0.4.jar,freemarker- 2.3.15.jar,ognl-2.7.3.jar,xwork-core-2.1.6.jar,struts2-core- 2.1.8.1.jar,commons-fileupload-1.2.1.jar,commons-collections- 3.2.jar,commons-lang-2.3.jar,commons-digester-2.0.jar,commons-beanutils- 1.7.0.jar,velocity-tools-1.4.jar,velocity-1.6.3.jar。
首先,web.xml文件,直接从下载的struts2压缩包中的blank项目中复制即可,无需其他多余配置
其次,struts.xml文件,先也从struts2的blank项目中复制一份,放到src目录下
再次,在WEB-INF下新建两个文件,velocity的配置velocity.properties和velocity tools的toolbox.xml(这两个文件的文件名随意)
第四,WEN-INF中新建一个VM_global_library.vm文件,内容为空
第五,在struts配置文件中加入下面两行,注意value的文件路径,就是第三步中新建的
<constant name="struts.velocity.toolboxlocation" value="WEB-INF/toolbox.xml" />
<constant name="struts.velocity.configfile" value="WEB-INF/velocity.properties" />
加入后:
<struts>
<constant name="struts.velocity.toolboxlocation" value="WEB-INF/toolbox.xml" />
<constant name="struts.velocity.configfile" value="WEB-INF/velocity.properties" />
<include file="struts-default.xml" />
<package name="default" extends="struts-default">
<action name="hello" class="test.Hello" method="execute">
<result name="success">hello.vm</result>
</action>
</package>
</struts>
第六,编码问题,统一编码,将所有文件的编码都给为同一种,如utf-8,同时在.vm文件中加上<meta http-equiv="content-type" content="text/html;charset=UTF-8" />,还要更改服务器的配置(如tomcat,打开tomcat conf目录下server.xml,找到你使用的Connector,不知道用哪个就改所有的Connector,在这个标签的最后加上 URIEncoding="UTF-8"(要跟前面一致))这样基本可以解决乱码问题
最后,写自己的.vm尝试尝试吧
- strust2和velocity的配置
- strust2 配置和学习
- Strust2 的result配置
- 【strust2】Action的配置
- Strust2+JSON的配置详解
- Strust2配置
- Tomcat和Velocity配置
- redirectAction新旧版配置的区别-Strust2
- strust2配置action的完整过程
- strust2的核心和工作原理
- Strust2 constant 配置
- 日常小结-strust2配置
- strust2 配置讲解
- velocity的使用-配置(Maven)
- velocity的默认配置路径
- spring中velocity的配置
- SpringMVC中Velocity的配置
- velocity中宏的配置
- android LayoutInflater的获取
- yaffs2文件系统移植
- 安装后新建Android出现“AndroidManifest.xml 系统找不到指定的文件”解决方案
- 【学习笔记】IOS(1)之UIAlertView
- 堆(Heap)的实现
- strust2和velocity的配置
- 比赛题目
- POJ 1088 滑雪(动态规划经典)
- 在Order By 中玩点花样——将匹配项在前的放前面
- 终于可以写了吗?
- SQLiteHelper-SQLite帮助类
- TCP协议三次握手过程分析
- 第三届蓝桥杯预赛第九题——趣味算式
- 安卓学习路线