如何将 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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 16:27:41  来源:igfitidea点击:

How to configure Struts Framework to Eclipse

eclipsejakarta-eestruts2

提问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

  1. Create a new Java EE project in Eclipse.
  2. Download the Apache Struts framework from its website.
  3. 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/libfolder 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
  4. Configure the Web application so that the Struts framework will handle all page requests by adding these lines to the web.xmlfile:

    <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>
    
  5. Create the struts.xmlconfiguration file.

  6. Create the JSPs you need.
  7. Build the application.
  1. 在 Eclipse 中创建一个新的 Java EE 项目。
  2. 从其网站下载 Apache Struts 框架。
  3. 如果您使用 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
  4. 配置 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>
    
  5. 创建struts.xml配置文件。

  6. 创建您需要的 JSP。
  7. 构建应用程序。

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