1:官网http://struts.apache.org/下载struts-2.3.31-all.zip
2:在MyEclipse中新建一个Web Project
3:解压刚才下载好的struts-2.3.31-all.zip
4:找到解压后的struts-2.3.31文件的目录下的apps文件夹下的struts2-blank.war解压
5:找到刚才解压的struts2-blank文件的目录下的WEB-INF下的lib文件夹下的jar包
、
6:将这些jar包全部拷贝到步骤2新建的Web Project的WebRoot下的WEB-INF下的lib文件中
7:找到struts-2.3.31\apps\struts-blank\WEB-INF\src\java下的struts.xml,将其拷贝到Web Project的src目录下
8:修改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>
<package name="struts2" extends="struts-default">
<action name="HelloWorld">
<result>/index.jsp</result>
</action>
</package>
</struts>
9:将struts-2.3.31\apps\struts2-blank\WEB-INF下的web.xml拷贝到Web Project的WebRoot的WEB-INF下
10:修改web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<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>
</web-app>
11:编写index.jsp
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>HelloStruts2</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
Hello Struts2 <br>
</body>
</html>