---
title: "Struts获取Web应用根目录"
author: "jis117"
date: "2014-08-15T09:14:53Z"
tags: []
categories: ["编程语言"]
slug: "struts-web"
draft: false
lastmod: "2014-08-15T09:14:53Z"
id: 2104178
url: "https://jis117.iteye.com/blog/2104178"
---

```java

ActionContext ac = ActionContext.getContext();
ServletContext sc = (ServletContext) ac.get(ServletActionContext.SERVLET_CONTEXT);
String temp = ServletActionContext.getRequest().getRealPath("/");

```