苹果笔记本优酷怎么看:[velocity]Struts2下配置Velocity1.6ss
来源:百度文库 编辑:九乡新闻网 时间:2024/04/30 04:17:09
先说一下环境吧。
Myeclipse6.5+Struts2.1.8+Velocity1.6.4。
在eclipse中创建一个web project。在/WEB-INF/lib/中添加Struts2和velocity所需要的jar包。虽然struts2中已经自带了velocity的jar包,但版本不是最新的。所以从apache官方网站的maven库中下载比较新的版本。
velocity需要的jar包如下:
velocity-1.6.4.jar
velocity-tools-1.4.jar
commons-collections-3.2.jar
commons-lang-2.3.jar
然后编辑web.xml
velocitylayout
org.apache.velocity.tools.view.servlet.VelocityViewServlet
velocitylayout
*.vm
在web.xml中添加对vm文件的处理。
然后在struts.xml中添加测试使用的action。
/hello.vm
随后在/WebRoot/下创建hello.vm
Velocity
然后是IndexAction。
public class IndexAction extends ActionSupport {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String execute() {
name = "Hello, " + name + "!";
return SUCCESS;
}
}
最后在index.jsp中
<%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
这个是测试Velocity的程序
提交action处理后返回hello.vm中。
最后在hello.vm中:
Velocity
Myeclipse6.5+Struts2.1.8+Velocity1.6.4。
在eclipse中创建一个web project。在/WEB-INF/lib/中添加Struts2和velocity所需要的jar包。虽然struts2中已经自带了velocity的jar包,但版本不是最新的。所以从apache官方网站的maven库中下载比较新的版本。
velocity需要的jar包如下:
velocity-1.6.4.jar
velocity-tools-1.4.jar
commons-collections-3.2.jar
commons-lang-2.3.jar
然后编辑web.xml
在web.xml中添加对vm文件的处理。
然后在struts.xml中添加测试使用的action。
随后在/WebRoot/下创建hello.vm
你好: $name
然后是IndexAction。
public class IndexAction extends ActionSupport {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String execute() {
name = "Hello, " + name + "!";
return SUCCESS;
}
}
最后在index.jsp中
<%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
提交action处理后返回hello.vm中。
最后在hello.vm中:
Message rendered in Velocity: $name
[velocity]Struts2下配置Velocity1.6ss
[velocity]Struts2下
Struts2 XML配置详解
简述STRUTS2 Convention零配置
struts2最简单的配置(不信你来看看)
Struts2教程3:struts.xml常用配置解析
Struts2 鲜为人知的调试技巧(下)
windows系统下JDK1.6环境变量配置
Velocity入门
Linux下配置网络
Struts2下多文件的上传与下载
windows系统下JDK1.6环境变量配置1
win2008下iis配置asp
linux下的vim配置
LINUX下Web服务器配置
Linux下安装配置Tomcat
LINUX下Subversion安装配置
Cygwin下vim的配置
linux下配置jsp环境
CHAPTER 3 Velocity介绍 - Velocity空间 - BlogJava
CentOS下NFS安装与配置 Centos5.3下安装配置NFS linux下安装配置NFS
CentOS下配置XDMCP的方法介绍
Linux下JDK的安装配置
Windows下VPN服务器配置详解