strust2.1.8的配置
? 准备配置Struts 2的一个简单应用,发现配置居然有错误。
严重: Dispatcher initialization failedUnable to load configuration. - bean - jar:file:/D:/eclipse/workplaces/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Struts2/WEB-INF/lib/struts2-core-2.1.8.1.jar!/struts-default.xml:53:89at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:58)at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:374)at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:418)at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:190)at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:295)at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:422)at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:115)at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3838)at org.apache.catalina.core.StandardContext.start(StandardContext.java:4488)at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)at org.apache.catalina.core.StandardService.start(StandardService.java:519)at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)at org.apache.catalina.startup.Catalina.start(Catalina.java:581)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)at java.lang.reflect.Method.invoke(Method.java:597)at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)Caused by: Unable to load bean: type: class:org.apache.struts2.views.freemarker.FreemarkerManager - bean - jar:file:/D:/eclipse/workplaces/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Struts2/WEB-INF/lib/struts2-core-2.1.8.1.jar!/struts-default.xml:53:89at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:221)at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:101)at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:169)at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:55)... 21 more
?
??? 一开始,只加了struts2-core-2.1.8.1.jar,xwork-core-2.1.5.jar和ognl-2.7.3.jar三个jar包,发现启动时也是配置错误。增加commons-fileupload-1.2.1.jar和commons-io-1.3.2.jar后,先前的错误得到解决。
??接下来的报错就是:
?
Unable to load bean: type: class:org.apache.struts2.views.freemarker.FreemarkerManager
? 我根本就没有用FreeMaker,竟然会报错FreeMaker,算了,先加上吧。增加freemarker-2.3.15.jar。
?问题竟然全部解决。
?由此,总结如下:
?如果需要开发Struts 2程序,必须包含以下6个jar
struts2-core-2.1.8.1.jarognl-2.7.3.jarxwork-core-2.1.6.jarcommons-fileupload-1.2.1.jarcommons-io-1.3.2.jarfreemarker-2.3.15.jar
?
?? 最后查看了一下Struts的Sample,发现struts2-blank-2.1.8.1中竟然完好的展示了我的猜测。
?
??
????
?