如何将 Struts 框架配置为 Eclipse
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6383000/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to configure Struts Framework to Eclipse
提问by Ganesh
I would like to add the struts framework to my eclipse helios j2ee version. Plese give me the guidance regarding this.
我想将 struts 框架添加到我的 eclipse helios j2ee 版本中。请给我这方面的指导。
Thanks in advance.
提前致谢。
回答by Alessandro Menti
- Create a new Java EE project in Eclipse.
- Download the Apache Struts framework from its website.
- If you use Maven as your build system, add the Structs artifact (see here). If you use another build system, unzip the downloaded framework and add these files to the
WEB_INF/lib
folder of your application:- commons-fileupload-X.X.X.jar
- commons-io-X.X.X.jar
- commons-logging-X.X.X.jar
- commons-logging-api.X.X.jar
- freemarker-X.X.X.jar
- ognl-X.X.X.jar
- struts2-core-X.X.X.X.jar
- xwork-core-X.X.X.jar
- javassist-3.7.ga.jar
Configure the Web application so that the Struts framework will handle all page requests by adding these lines to the
web.xml
file:<filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
Create the
struts.xml
configuration file.- Create the JSPs you need.
- Build the application.
- 在 Eclipse 中创建一个新的 Java EE 项目。
- 从其网站下载 Apache Struts 框架。
- 如果您使用 Maven 作为构建系统,请添加 Structs 工件(请参阅此处)。如果您使用其他构建系统,请解压缩下载的框架并将这些文件添加到
WEB_INF/lib
您的应用程序文件夹中:- 公共文件上传-XXXjar
- commons-io-XXXjar
- 公共日志记录XXXjar
- commons-logging-api.XXjar
- freemarker-XXXjar
- ognl-XXXjar
- struts2-core-XXXXjar
- xwork-core-XXXjar
- javassist-3.7.ga.jar
配置 Web 应用程序,以便 Struts 框架通过将这些行添加到
web.xml
文件中来处理所有页面请求:<filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
创建
struts.xml
配置文件。- 创建您需要的 JSP。
- 构建应用程序。
Source (and further information): http://struts.apache.org/2.2.3/docs/create-struts-2-web-application-with-artifacts-in-web-inf-lib-and-use-ant-to-build-the-application.html
来源(和更多信息):http: //struts.apache.org/2.2.3/docs/create-struts-2-web-application-with-artifacts-in-web-inf-lib-and-use-ant -to-build-the-application.html
One more jar you need to add that is commons-lang3-x.x.jar
您还需要添加一个 jar 是 commons-lang3-xxjar