---
title: "ssh框架获取ServletContext实例"
author: "chen1255"
date: "2010-01-29T10:37:30Z"
tags: []
categories: ["编程语言"]
slug: "ssh-servletcontext"
draft: false
lastmod: "2010-01-29T10:37:30Z"
id: 583119
url: "https://chen1255.iteye.com/blog/583119"
---

最近我在网上发现很多人在使用ssh（struts1.x+spring+hibernate）框架时，无法取得ServletContext，同时也有很多回答，但大部分都是一知半解或是很多文章都是一样的，相互抄袭，对把家的帮助不大。这几天我专门抽了一点时间来解决这个问题，因为有很多组件会使用到这个对象，比如说jspSmartupload等，希望给大家带来方便，如果有错误希望大家理解及反馈

内容：

起初，我们在使用纯struts的时候，我们可以很容易得到ServletContext，因为struts实现了getServletContext这个方法，它返回了一个ServletContext对象，这是Action.class的实现方法：


 



view plaincopy to clipboardprint?
   public ActionServlet getServlet() {   
        return (this.servlet);   
}   



[查看全文](http://blog.csdn.net/chen1255/archive/2010/01/29/5268246.aspx)