---
title: "struts2 所需jar包详解 "
author: "Jellen129"
date: "2010-08-18T13:14:03Z"
tags: ["Apache", "Struts", "freemarker"]
categories: ["企业架构"]
slug: "struts2-jar"
draft: false
lastmod: "2010-08-18T13:14:03Z"
id: 740073
url: "https://jellen129.iteye.com/blog/740073"
---

**Struts2** .1.x终于推出正式版了，下载后按照 **Struts2** .0.14版进行配置，抛出异常说无法装载 (org.apache. **Struts2** . dispatcher.multipart.MultiPartRequest)，异常信息提示摘不到 org.apache.commons.fileupload.RequestContext类，搜索 Struts2 .1.6带的所有jar包，发现RequestContext类并不在 **Struts2** -core-2.1.6.jar 中，在commons-fileupload-1.2.1.jar包中，之前 **Struts2** .0.14并不需要此包，只有在要用到上传组件的时候才需要。可能是 Struts2 .1.6对文件上传功能的改进。因此要想正常使用 Struts2 .1.6，至少需要如下6 个jar包：

- **Struts2** -core-2.1.6.jar
- freemarker-2.3.13.jar
- commons-logging-1.0.4.jar
- ognl-2.6.11.jar
- xwork-2.1.2.jar
- commons-fileupload-1.2.1.jar
  
  要注意的是， **Struts2** .1.6的最小jar包配置比 **Struts2** .0.14多了一个commons-fileupload-1.2.1.jar。  
  如果要使用 Struts2 的注释功能，在 Struts2 .0.14中只要引用了 Struts2 -core-2.1.6.jar文件即可，而在 Struts2 .1.6中还需要引用 Struts2 -convention-plugin-2.1.6.jar文件，而且注释类的包也变了（又增加了一些新的注释类）， **Struts2** .0.14中的注释类在org.apache. Struts2 .config包中，而 **Struts2** .1.6的注释类在 org.apache. **Struts2** .convention.annotation包中。除此之外，有些注释的属性名也变了，如Result注释在 Struts2 .0.14中有一个value属性，表示一个要转入的URL，而在 Struts2 .1.6的Result注释中使用location属性代替了value属性（不再有value属性了），但它们的使用方法相同。  
  因此，读者在使用 Struts2 .1.x时要注意，这一版本与 **Struts2** .0.x并不完全兼容（但大部分还是兼容的）。据我的经验， **Struts2** .1.x版本将是比较稳定的一个 **Struts2** 版本，因此，Struts1.x就是在Struts1.1版本才开始流行起来的。  
  以前也测试过 **Struts2** 的其他版本，经部分测试，目前Struts 2分为三个版本阶段：Struts 2.0.9及以前版本、 **Struts2** .0.10至 **Struts2** .0.14、Struts 2.1.x，这三类版本都不太兼容，如果确定使用 **Struts2** 来开发程序，建议直接使用 **Struts2** .1.6及以后的版本，这是一个比较稳定的 **Struts2** 版本。