1、导入jar包
2、拷贝修改配置文件struts.xml,web.xml
将struts.xml文件拷贝到src目录下,改为如下配置
<?
xml
version
=
"1.0"
encoding
=
"UTF-8"
?>
<!
DOCTYPE
struts
PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd"
>
<
struts
>
<!-- 配置为开发模式 -->
<
constant
name
=
"struts.devMode"
value
=
"true"
/>
<!-- 把扩展名配置为action -->
<
constant
name
=
"struts.action.extension"
value
=
"action"
/>
<!-- 把主题配置为simple -->
<
constant
name
=
"struts.ui.theme"
value
=
"simple"
/>
<
package
name
=
"default"
namespace
=
"/"
extends
=
"struts-default"
>
</
package
>
<!-- Add packages here -->
</
struts
>
将web.xml文件配置成如下形式
<?
xml
version
=
"1.0"
encoding
=
"UTF-8"
?>
<
web-app
version
=
"2.5"
xmlns
=
"http://java.sun.com/xml/ns/javaee"
xmlns:xsi
=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation
=
"http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
>
<
display-name
></
display-name
>
<
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
>
<
welcome-file-list
>
<
welcome-file
>
index.jsp
</
welcome-file
>
</
welcome-file-list
>
</
web-app
>
ps:xml自动提示设置:
window ==> preferences ==> 搜索xml ==> xml catalog ==> key type改为URI ==> 选择dtd文件路径 ==>复制key为dtd文件名