项目运行后404,控制台也报错,求解

来源:4-3 配置Action,Service,Dao的类-Struts2整合Spring

慕侠8922259

2019-07-14 00:56

先附上代码

web.xml

https://img4.mukewang.com/5d2a0bda0001dbc614040647.jpg

页面:

https://img.mukewang.com/5d2a0bfc0001470f12520668.jpg

ProductAction:

https://img2.mukewang.com/5d2a0c220001f98a11630674.jpg

ProductDao:

https://img1.mukewang.com/5d2a0c300001e13607480569.jpg

ProductService:

https://img3.mukewang.com/5d2a0c4e0001c41907070653.jpg

applicationContext.xml:

https://img3.mukewang.com/5d2a0c6c0001acf112770630.jpg

struts.xml:

https://img2.mukewang.com/5d2a0c7b0001246b12560425.jpg

控制台输出:

严重: Exception sending context initialized event to listener instance of class [org.springframework.web.context.ContextLoaderListener]

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'productService' defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean 'productDao' while setting bean property 'productDao'; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [cn.muke.ssh.service.ProductDao] for bean with name 'productDao' defined in class path resource [applicationContext.xml]; nested exception is java.lang.ClassNotFoundException: cn.muke.ssh.service.ProductDao

at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:329)

at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:107)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1391)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1132)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:522)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)

at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:607)

at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)

at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383)

at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)

at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)

at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4770)

at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5236)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:754)

at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:730)

at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:744)

at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1135)

at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1869)

at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)

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:745)

Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [cn.muke.ssh.service.ProductDao] for bean with name 'productDao' defined in class path resource [applicationContext.xml]; nested exception is java.lang.ClassNotFoundException: cn.muke.ssh.service.ProductDao

at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1263)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:438)

at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)

at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:323)

... 28 more

Caused by: java.lang.ClassNotFoundException: cn.muke.ssh.service.ProductDao

at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1364)

at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1185)

at org.springframework.util.ClassUtils.forName(ClassUtils.java:258)

at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:415)

at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1284)

at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1255)

... 34 more

七月 14, 2019 12:53:28 上午 org.apache.catalina.core.StandardContext startInternal

严重: One or more listeners failed to start. Full details will be found in the appropriate container log file

七月 14, 2019 12:53:28 上午 org.apache.catalina.core.StandardContext startInternal

严重: Context [/ssh] startup failed due to previous errors

七月 14, 2019 12:53:28 上午 org.apache.catalina.core.ApplicationContext log

信息: Closing Spring root WebApplicationContext

七月 14, 2019 12:53:28 上午 org.apache.catalina.startup.HostConfig deployDirectory

信息: Deployment of web application directory [D:\Tomcat\webapps\ssh] has finished in [3,112] ms

七月 14, 2019 12:53:28 上午 org.apache.coyote.AbstractProtocol start

信息: Starting ProtocolHandler ["http-nio-8080"]

七月 14, 2019 12:53:28 上午 org.apache.coyote.AbstractProtocol start

信息: Starting ProtocolHandler ["ajp-nio-8009"]

七月 14, 2019 12:53:28 上午 org.apache.catalina.startup.Catalina start

信息: Server startup in 3735 ms

页面输出:

https://img4.mukewang.com/5d2a0cc20001c35911410488.jpg

控制台最后输出:

七月 14, 2019 12:54:05 上午 org.apache.tomcat.util.http.parser.Cookie logInvalidHeader

信息: A cookie header was received [1561474792,1562239112] that contained an invalid cookie. That cookie will be ignored.Note: further occurrences of this error will be logged at DEBUG level.


烦请大家帮忙看下原因,谢谢


写回答 关注

1回答

  • weixin_慕婉清6397184
    2019-07-27 10:24:28

    404是找不到网页,struts.xml文件需要在action下写一个<result name="action中return的字符串">xxxx.jsp</result>

基于SSH实现员工管理系统之框架整合篇

本视频教程主要介绍环境搭建和SSH框架整合,逐层深入理解学习

49831 学习 · 344 问题

查看课程

相似问题