Eclipse配置Struts2

第一步: 

需要把下载下来的struts压缩包解压,把lib文件夹下的jar拷贝到项目的lib下面。

以下是最少的jar包。

 

第二步:

把*struts-2.3.24.1-allstruts-2.3.24.1appsstruts2-blankWEB-INFclasses下的struts.xml文件拷贝到src中,并配置 struts.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
    "http://struts.apache.org/dtds/struts-2.3.dtd"
>

<struts>
<constant name="struts.devMode" value="true" />
<package name="default" namespace="/" extends="struts-default">
    <action name="hello">
        <result>/hello.jsp</result>
    </action>
</package>
</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>

        

原文地址:https://www.cnblogs.com/bluewhy/p/4869343.html