这个问题在这里已经有了答案:
spring如何在struts操作中注入applicationcontext.xml中未定义的属性(1个答案)
上个月关门了。
我试图在tomcat服务器上部署struts+spring+hibernate应用程序,但是struts配置出现了一些错误,即在struts.xml中我使用了一个bean editEmployeeAction
在spring.xml上定义,但在部署应用程序时,tomcat未能加载操作[not found action]
请帮我解决这个问题!
spring.xml文件
...
<!-- This bean has been referred fron struts.xml file; So type it correctly; -->
<!-- Make scope prototype; This is really important. -->
<bean id="editEmployeeAction" class="me.modernpage.controller.EditEmployeeAction"
scope="prototype">
<property name="employeeManager">
<ref bean="employeeManager"/>
</property>
</bean>
<bean id="employeeDAO" class="me.modernpage.dao.EmployeeDAOImpl">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<bean id="employeeManager" class="me.modernpage.service.EmployeeManagerImpl">
<property name="employeeDAO">
<ref bean="employeeDAO"/>
</property>
</bean>
...
struts.xml位于src上/
<struts>
<constant name="struts.devMode" value="true" />
<constant name="struts.custom.i18n.resources" value="messages" />
<constant name="struts.enable.SlachesInActionNames" value="true" />
<package name="default" namespace="" extends="struts-default">
<!-- Two things to Notice:
1) class is set to 'editEmployeeAction' which is bean defined by Spring context
2) We have given the method to be called here as well; -->
<action name="list" class="editEmployeeAction" method="listEmployees">
<result>/view/editEmployeeList.jsp</result>
</action>
<action name="add" class="editEmployeeAction" method="addEmployee">
<result type="redirect">/list</result>
</action>
<action name="delete/*" class="editEmployeeAction" method="deleteEmployee">
<param name="employee.id">{1}</param>
<result type="redirect">/list</result>
</action>
<action name="*" class="editEmployeeAction" method="listEmployees">
<result>/view/editEmployeeList.jsp</result>
</action>
</package>
</struts>
在这里,您可以看到'class'的值是ediemployeelist bean,那么我认为tomcat找不到这个bean?!
错误:
23:06:57,021 ERROR Dispatcher:42 - Dispatcher initialization failed
无法加载配置。-操作-文件:/home/yusuf/tomcat/apache-tomcat-9.0.24/web/spring\u struts\u hibernate/web-inf/classes/struts。xml:17:73在com.opensymphony.xwork2.config.configurationmanager.getconfiguration(configurationmanager。java:70)在org.apache.struts2.dispatcher.dispatcher.getcontainer(dispatcher。java:978)在org.apache.struts2.dispatcher.dispatcher.init\u配置(dispatcher。java:446)在org.apache.struts2.dispatcher.dispatcher.init(dispatcher。java:490)在org.apache.struts2.dispatcher.ng.initoperations.initdispatcher(initoperations。java:74)在org.apache.struts2.dispatcher.ng.filter.strutsprepareandexecutefilter.init(strutsprepareandexecutefilter。java:57)在org.apache.catalina.core.applicationfilterconfig.initfilter(applicationfilterconfig。java:270)在org.apache.catalina.core.applicationfilterconfig.getfilter(applicationfilterconfig。java:251)在org.apache.catalina.core.applicationfilterconfig.(applicationfilterconfig。java:102)在org.apache.catalina.core.standardcontext.filterstart(standardcontext。java:4533)在org.apache.catalina.core.standardcontext.startinternal(standardcontext。java:5172)在org.apache.catalina.util.lifecyclebase.start(lifecyclebase。java:183)在org.apache.catalina.core.containerbase$startchild.call(containerbase。java:1384)在org.apache.catalina.core.containerbase$startchild.call(containerbase。java:1374)在java.util.concurrent.futuretask.run(futuretask。java:266)位于org.apache.tomcat.util.threads.inlineexecutorservice.execute(inlineexecutorservice。java:75)在java.util.concurrent.abstractexecutorservice.submit(abstractexecutorservice。java:134)在org.apache.catalina.core.containerbase.startinternal(containerbase。java:909)在org.apache.catalina.core.standardhost.startinternal(standardhost。java:841)在org.apache.catalina.util.lifecyclebase.start(lifecyclebase。java:183)在org.apache.catalina.core.containerbase$startchild.call(containerbase。java:1384)在org.apache.catalina.core.containerbase$startchild.call(containerbase。java:1374)在java.util.concurrent.futuretask.run(futuretask。java:266)位于org.apache.tomcat.util.threads.inlineexecutorservice.execute(inlineexecutorservice。java:75)在java.util.concurrent.abstractexecutorservice.submit(abstractexecutorservice。java:134)在org.apache.catalina.core.containerbase.startinternal(containerbase。java:909)在org.apache.catalina.core.standardengine.startinternal(standardengine。java:262)在org.apache.catalina.util.lifecyclebase.start(lifecyclebase。java:183)在org.apache.catalina.core.standardservice.startinternal(标准服务。java:421)在org.apache.catalina.util.lifecyclebase.start(lifecyclebase。java:183)在org.apache.catalina.core.standardserver.startinternal(standardserver。java:932)在org.apache.catalina.util.lifecyclebase.start(lifecyclebase。java:183)在org.apache.catalina.startup.catalina.start(catalina。java:633)在sun.reflect.nativemethodaccessorimpl.invoke0(本机方法)在sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl)。java:62)在sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl。java:43)在java.lang.reflect.method.invoke(方法。java:498)在org.apache.catalina.startup.bootstrap.start(引导。java:344)在org.apache.catalina.startup.bootstrap.main(bootstrap。java:475)原因:操作类[editemployeeaction]未找到-操作-文件:/home/yusuf/tomcat/apache-tomcat-9.0.24/web/spring\u struts\u hibernate/web-inf/classes/struts。xml:17:73在com.opensymphony.xwork2.config.providers.xmlconfigurationprovider.verifyaction(xmlconfigurationprovider。java:486)在com.opensymphony.xwork2.config.providers.xmlconfigurationprovider.addaction(xmlconfigurationprovider。java:429)在com.opensymphony.xwork2.config.providers.xmlconfigurationprovider.addpackage(xmlconfigurationprovider。java:556)在com.opensymphony.xwork2.config.providers.xmlconfigurationprovider.loadpackages(xmlconfigurationprovider。java:295)在org.apache.struts2.config.strutsxmlconfigurationprovider.loadpackages(strutsxmlconfigurationprovider。java:112)在com.opensymphony.xwork2.config.impl.defaultconfiguration.reloadcontainer(defaultconfiguration。java:264)在com.opensymphony.xwork2.config.configurationmanager.getconfiguration(配置管理器。java:67) ... 38个以上
1条答案
按热度按时间velaa5lx1#
最后,我了解了问题的原因,该项目缺少struts-spring插件库来链接struts和spring。
strust2Spring插件