新建一个struts2项目

1,新建-动态web项目;

2,将struts2的必要jar包复制到WEB-INFlib文件夹下,一共有9个,如图一所示。



图一

3,配置web.xml文件,将以下内容写到web.xml文件中。

  <filter>
   <filter-name>struts2</filter-name> 
   <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
 </filter>
<!-- 配置filter拦截的url -->
<filter-mapping>
   <filter-name>struts2</filter-name> 
   <url-pattern>*.action</url-pattern> 
</filter-mapping>
<filter-mapping>
   <filter-name>struts2</filter-name> 
   <url-pattern>*.jsp</url-pattern> 
</filter-mapping>

<welcome-file-list>
        <welcome-file>content/index.jsp</welcome-file> //每个人的都可能不一样,我的index.jsp存放在WebContentcontent文件夹下
    </welcome-file-list>

原文地址:https://www.cnblogs.com/james1207/p/3265413.html