我使用的是struts2应用程序,但它要求spring配置
当我试图从沙盒中单独运行曼宁示例时,我遇到了以下错误 错误如下:我使用的是struts2应用程序,但它要求spring配置,struts2,Struts2,当我试图从沙盒中单独运行曼宁示例时,我遇到了以下错误 错误如下: You might need to add the following to web.xml: <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> Jun 17, 2013 7:17:39 AM org.a
You might need to add the following to web.xml:
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
Jun 17, 2013 7:17:39 AM org.apache.catalina.core.StandardContext filterStart
SEVERE: Exception starting filter struts2
java.lang.NullPointerException
at com.opensymphony.xwork2.spring.SpringObjectFactory.getClassInstance(SpringObjectFactory.java:188)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.verifyResultType(XmlConfigurationProvider.java:479)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addResultTypes(XmlConfigurationProvider.java:450)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:407)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:239)
at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:111)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reload(DefaultConfiguration.java:152)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:52)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:395)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:452)
at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:201)
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:4072)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4726)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
您可能需要将以下内容添加到web.xml中:
org.springframework.web.context.ContextLoaderListener
2013年6月17日上午7:17:39 org.apache.catalina.core.StandardContext filterStart
严重:启动过滤器struts2时出现异常
java.lang.NullPointerException
位于com.opensymphony.xwork2.spring.SpringObjectFactory.getClassInstance(SpringObjectFactory.java:188)
位于com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.verifyResultType(XmlConfigurationProvider.java:479)
在com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addResultTypes上(XmlConfigurationProvider.java:450)
位于com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:407)
在com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:239)
位于org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:111)
在com.opensymphony.xwork2.config.impl.DefaultConfiguration.reload(DefaultConfiguration.java:152)上
在com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:52)上
位于org.apache.struts2.dispatcher.dispatcher.init\u预配置(dispatcher.java:395)
位于org.apache.struts2.dispatcher.dispatcher.init(dispatcher.java:452)
位于org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:201)
位于org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:295)
位于org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:422)
位于org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:115)
位于org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4072)
位于org.apache.catalina.core.StandardContext.start(StandardContext.java:4726)
位于org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
位于org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
位于org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
位于org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
位于org.apache.catalina.core.StandardService.start(StandardService.java:525)
位于org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
位于org.apache.catalina.startup.catalina.start(catalina.java:595)
在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处
位于sun.reflect.NativeMethodAccessorImpl.invoke(未知源)
在sun.reflect.DelegatingMethodAccessorImpl.invoke处(未知源)
位于java.lang.reflect.Method.invoke(未知源)
位于org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
位于org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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.FilterDispatcher</filter-class>
<init-param>
<param-name>actionPackages</param-name>
<param-value>manning</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>anotherServlet</servlet-name>
<servlet-class>manning.servlet.AnotherServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>anotherServlet</servlet-name>
<url-pattern>/anotherServlet</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
支柱2
org.apache.struts2.dispatcher.FilterDispatcher
行动包
在…岗位上工作
支柱2
/*
另一个servlet
manning.servlet.AnotherServlet
另一个servlet
/另一个servlet
index.html
struts.xml
<?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>
<!--
For the purposes of the book, we will leave devMode set to true. This
allows several things to occur including provision of debugging level information
on error pages as well as reloading of various resources with each request.
-->
<constant name="struts.devMode" value="true" />
<!--
You can define packages directly in this file, but its probably best
to modularize the configuration files with separate xml files for each
package. Ulitmately its all the same because the include element, seen
below, pulls the included configuration document directly in to the
primary document. The only thing to consider is that a referenced
element must have been declared above the referring element.
-->
<!--
This is the menu action that will allow the reader to see the different
samples actions from the different chapters in a menu format. We declare
it here, in the root namespace, because its not really related to any of the
specific examples or chapters, its just a kind of utility for the whole
application.
-->
<package name="default" namespace="/" extends="struts-default">
<action name="Menu">
<result>/menu/Menu.jsp</result>
</action>
</package>
<include file="manning/chapterTwo/chapterTwo.xml"/>
<include file="manning/chapterThree/chapterThree.xml"/>
<include file="manning/chapterThree/objectBacked/chapterThree.xml"/>
<include file="manning/chapterThree/modelDriven/chapterThree.xml"/>
<include file="manning/chapterFour/chapterFour.xml"/>
<include file="manning/chapterFive/chapterFive.xml"/>
<include file="manning/chapterSix/chapterSix.xml"/>
<include file="manning/chapterSeven/chapterSeven.xml"/>
<include file="manning/chapterEight/chapterEight.xml"/>
<include file="manning/chapterNine/chapterNine.xml"/>
<include file="manning/chapterTen/chapterTen.xml"/>
<include file="manning/chapterEleven/chapterEleven.xml"/>
</struts>
/menu/menu.jsp
为什么我会出错。我已经删除了web.xml中有关spring的一些配置,请将过滤器更改为下面的
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
支柱2
org.apache.struts2.dispatcher.ng.filter.strutspreadexecutefilter
如果您的类路径中有这个jar并且不想使用spring与struts2的集成,请从类路径中删除struts2 spring插件-*.jar
如果您仍然面临问题,请告诉我,您应该阅读代码随附的readme.txt文件。您收到错误是因为您在
web.xml
中删除了一些有关Spring的配置,但应用程序仍在尝试使用Spring。此外,该筛选器已弃用。