strust2.1以上版本需要的包

运行struts2时遇到:错误 "Dispatcher initialization failed java.lang.RuntimeException: java.lang.reflect.InvocationTargetException”

处理方法:
1、核对lib包

commons-fileupload-1.2.1.jar,
commons-io-1.3.2.jar
commons-logging-1.0.4.jar
freemarker-2.3.16.jar
ognl-3.0.jar
struts2-core-2.2.1.jar
xwork-core-2.2.1.jar

注意2.1以前是没有commons-fileupload-1.2.1.jar,

2、如果struts2版本是2.1以前

web.xml配置过滤器的时候应该是这样:

view plaincopy to clipboardprint?
<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>
<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>


如果struts2 版本是2.1以上

web.xml配置

view plaincopy to clipboardprint?
<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>
<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>


3、

在使用struts-2.2.1时,需要引入javassist-3.7.ga.jar,而这个在struts-2.2.1\lib下是没有的,需要在struts-2.2.1\apps\struts2-blank-2.2.1.war下的lib中找。



所以在struts2.1以上的版本要引入的包应该是8个包

commons-fileupload-1.2.1.jar,
commons-io-1.3.2.jar
commons-logging-1.0.4.jar
freemarker-2.3.16.jar

javassist-3.7.ga.jar
ognl-3.0.jar
struts2-core-2.2.1.jar
xwork-core-2.2.1.jar

你可能感兴趣的:(apache,xml,freemarker,Web,struts)