我正在努力实施STRUTS SPRING和HIBERNATE INTEGRATION ON ONLINE EXAMINATION。使用apache tomcat 7.0.42在Eclipse Kepler中运行项目时,它会抛出以下错误
**HTTP Status 404 - /OnlineExam/registration.jsp**
**Description:**The requested resource is not available.
在控制台日志中,出现以下内容,
SEVERE: Exception starting filter struts2
Unable to load configuration. - action - file:/C:/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp3/wtpwebapps/iSAS/WEB-INF/classes/struts.xml:16:73
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:431)
at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:51)
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:4775)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5452)
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(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:724)
Caused by: Unable to load configuration. - action - file:/C:/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp3/wtpwebapps/iSAS/WEB-INF/classes/struts.xml:16:73
at 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)
... 14 more
Caused by: Error building results for action userRegistration in namespace - action - file:/C:/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp3/wtpwebapps/iSAS/WEB-INF/classes/struts.xml:16:73
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addAction(XmlConfigurationProvider.java:367)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:468)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:264)
at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:111)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:193)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:55)
... 16 more
Caused by: There is no result type defined for type 'tiles' mapped with name 'SUCCESS'. Did you mean 'tiles'? - result - file:/C:/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp3/wtpwebapps/iSAS/WEB-INF/classes/struts.xml:17:40
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.buildResults(XmlConfigurationProvider.java:621)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addAction(XmlConfigurationProvider.java:365)
... 21 more
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>
<constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory" />
<constant name="struts.ui.theme" value="simple" />
<constant name="struts.devMode" value="true" />
<package name="default" extends="struts-default">
<result-types>
<result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult"/>
</result-types>
<action name="userRegistration" method="{1}" class="userRegistration">
<result name="SUCCESS" type="tiles">isas.user.registration</result>
<result name="ERROR" type="tiles">isas.errorPage</result>
<result name="input" type="tiles">isas.user.registration</result>
</action>
</package>
</struts>
请帮帮我朋友。我不知道为什么会这样。无论如何,谢谢你提前...... !!!
答案 0 :(得分:1)
我认为你错过了“struts2-spring-plugin-2.1.6.jar”文件,请在你的类路径中查看
答案 1 :(得分:0)
我得到了同样的错误,然而,添加jar并没有解决我的问题。
错误说明:Unable to load configuration. - action - file:/C:/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp3/wtpwebapps/iSAS/WEB-INF/classes/
struts.xml:16:73
第16行的struts.xml存在问题,即
<action name="userRegistration"
方法=&#34; {1}&#34; class="userRegistration">
struts尝试从类userRegistration加载名为{1}的方法。可能该方法不存在,因为它是一个无效的Java名称。我不确定struts是否接受像{1}那样的表示法来引用类中的第一个方法(可能不是),但在我的情况下,那就是问题:在struts.xml中,在action标签中,我是引用一个名称拼写错误的方法,因此struts试图找到一个不存在的方法,导致此错误 - 无法加载配置。
答案 2 :(得分:0)
修复了问题。希望解决方案对其他人有用:
struts.xml文件必须出现在WebContent下 - WEB-INF - classes - 使用eclipse时的struts.xml
我犯的错误是当我做了一个干净的项目时,它曾用于删除类文件夹下的文件,所以请确保该特定文件存在。