1 下载地址
http://struts.apache.org/download.cgi
2 复制 jar到 tomcat/lib 目录
3 复制 struct2-blank-2.0.11.war 到 webapps 目录
4 启动tomcat
竟然发现无法启动,产生 Error filterStart 错误
经多方查找,
1 去掉了lib目录下面老版本的相同的包,只保留新版本的
2 我最后去掉了sturt2 开头的所有内容,因为发现在那个war里面内置了 strut2 的包
启动成功。
5 输入
http://127.0.0.1:8080/struts2-blank-2.0.11/example/HelloWorld.action
显示 Loading... 然后显示
Struts is up and running ...
Languages
English
Espanol
正常了!
6 将 webapps/struts2-blank-2.0.11/WEB-INF/lib/ 的jar 移动到 tomcat/lib 下面
然后删除 struts2-blank-2.0.11.war 文件
再次启动
正常,看来存在重复的strut2 的包,会导致启动错误,也就是说,在tomcat\lib下存在的包,就不要再 WEB-INF\lib下面再次存在了!
有点奇怪哦!
文档显示,stuct2最小配置的jar包为
| Filename | Description |
| struts2-core.jar | Framework library itself, found in distribution root directory |
| xwork.jar | XWork 2 library on which Struts 2 is built (version 2.0 or later) |
| ognl.jar | Object Graph Navigation Language (OGNL), the expression language used throughout the framework |
| freemarker.jar | All UI tag templates are written in Freemarker (also a good option for your own views) |
| commons-logging.jar | Commons logging, which the framework uses to support transparently logging to either Log4J or JDK 1.4+ |
| web.xml | Java web application configuration file that defines the filters (and other components) for your web application |
| struts.xml | Framework configuration file that defines the actions, results, and interceptors for your application |
7 查看其web.xml 最低配置为
<?xml version="1.0"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>My Application</display-name>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
stucts.xml
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts><!-- Configuration for the default package. -->
<package name="default" extends="struts-default">
...
</package>
</struts>