苹果笔记本使用感受:[velocity]Struts2下
来源:百度文库 编辑:九乡新闻网 时间:2024/05/03 08:09:36
先说一下环境吧。
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下
[velocity]Struts2下配置Velocity1.6ss
Struts2 鲜为人知的调试技巧(下)
Velocity入门
Struts2下多文件的上传与下载
CHAPTER 3 Velocity介绍 - Velocity空间 - BlogJava
Struts2实例教程
struts2 ajaxf
struts2 doubleselect
Struts2标签
CHAPTER 14 在Turbine里使用Velocity - Velocity空间 -...
Struts2教程1:第一个Struts2程序
CHAPTER 2 MVC 基本原理 - Velocity空间 - BlogJava
Struts2 XML配置详解
Struts2教程t
struts2中文乱码解决方法
Struts2?页面数据处理
struts2文件上传
struts2多文件上传
struts2学习总结
struts2实现文件上传
Struts2上传文件-2
struts2.x学习总结
Struts2教程1:第一个Struts2程序 - 哈佛校训 - BlogJava