异常启动过滤器支柱2 无法加载配置:无法加载支柱.xml文件



我编写了下面提到的struts.xml文件并在Eclipse上运行,但是我得到了一个错误。

我也直接清洁雄猫工作

错误是:

Unable to load configuration. - file:/D:/Sonali_workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/salesdeals123/WEB-INF/classes/struts.xml:22:21
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:501)
at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:57)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:281)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:262)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:107)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4797)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5473)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: Unable to load configuration. - file:/D:/Sonali_workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/salesdeals123/WEB-INF/classes/struts.xml:22:21
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:445)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:489)
... 14 more
Caused by: Unable to load file:/D:/Sonali_workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/salesdeals123/WEB-INF/classes/struts.xml - file:/D:/Sonali_workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/salesdeals123/WEB-INF/classes/struts.xml:22:21
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadConfigurationFiles(XmlConfigurationProvider.java:1022)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadDocuments(XmlConfigurationProvider.java:165)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.init(XmlConfigurationProvider.java:132)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:233)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
... 16 more
Caused by: Element type "action-mappings" must be declared. - file:/D:/Sonali_workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/salesdeals123/WEB-INF/classes/struts.xml:22:21
at com.opensymphony.xwork2.util.DomHelper.parse(DomHelper.java:119)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadConfigurationFiles(XmlConfigurationProvider.java:1017)
... 20 more
Caused by: org.xml.sax.SAXParseException; systemId: file:/D:/Sonali_workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/salesdeals123/WEB-INF/classes/struts.xml; lineNumber: 22; columnNumber: 21; Element type "action-mappings" must be declared.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.startElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(Unknown Source)
at com.opensymphony.xwork2.util.DomHelper.parse(DomHelper.java:117) 

我的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>
<!-- The struts-default package is the Struts 2 default package. 
It defines default result types, interceptors, interceptor stacks, and a few other defaults.. -->
<package name="default" namespace="/" extends="struts-default">
<interceptors>   
<interceptor name="myCustomInterceptor" class="com.demo.struts.Interceptors.MyCustomInterceptor" />
<interceptor-stack name="customStack">
<interceptor-ref name="myCustomInterceptor"/>
<interceptor-ref name="defaultStack"/>
</interceptor-stack>
</interceptors>      
</package>


<package namespace="/user" name="default" extends="struts-default">


<action name="checkLoginDetail123" class="com.demo.struts.controller.FranchiseLogin_manager">
<result name="success">/Franchise/FranchiseExecutiveRegistration.jsp</result>
<result name="error">/Franchise/Login.jsp</result>
</action>

</package>

<constant name="struts.devMode" value="true" />
<constant name="struts.convention.default.parent.package"
value="default" />
<constant name="struts.custom.i18n.resources" value="global" />


</struts>

答案已经在堆栈跟踪:)

原因:org.xml.sax.SAXParseException; systemId: file:/D:/Sonali_workplace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/salesdeals123/WEB-INF/classes/struts.xml; 行号: 22;列数: 21;元素类型"操作映射"必须 被声明。

错误罪魁祸首的文件在WEB-INF/classes/struts.xml中。

struts.xml配置文件应位于源文件夹中, 如srcresources。构建应用程序时 编译输出定向到WEB-INF/classes

你可以检查这个文件 在使用已部署的 Web 部署或启动服务器之前存在 应用。

最新更新