---
title: "struts2下velocity做视图如何访问request,session等内置对象"
author: "DavyLee"
date: "2008-01-23T09:55:48Z"
tags: []
slug: "struts2-velocity-request-session"
draft: false
lastmod: "2008-01-23T09:55:48Z"
id: 158546
url: "https://davylee.iteye.com/blog/158546"
---

Struts2环境下用velocity做视图时访问jsp内置变量的方法。
经过研究发现,struts2条件下,velocity里访问jsp那几个内置变量,是需要写完整名字的,比如原来webwork2里的$req在struts2下要写$request
具体陈列如下：
（1）访问request对象：$request;
 (2) 访问response对象：$response;
 (3) 访问session对象：$session或$request.session或$request.getSession();
 (4) 访问application对象：$application(未亲自测试)