HTTP Status 500 - No bean named

HTTP Status 500 - No bean named

HTTP Status 500 - No bean named 'controller' is defined

type Exception report

message No bean named 'controller' is defined

description The server encountered an internal error that prevented it from fulfilling this request.

exception

org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'controller' is defined
org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:660)
org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1157)
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:280)
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:956)
com.imooc.smm.global.DispatcherServlet.service(DispatcherServlet.java:44)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
com.imooc.smm.global.encodingFilter.doFilter(encodingFilter.java:19)


正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

1回答
chrismorgen 2019-03-06 19:00:07

你好同学,如下报错提示是在spring容器中找不到名为contrller这个bean对象,建议你在当前项目中有没有名为controller这个bean呢?主要检查代码中的controller是否有@Controller("controller")这个注解呢,祝学习愉快~

http://img1.sycdn.imooc.com//climg/5c7fa5cd000130e605110148.jpg

  • 提问者 月鑫 #1
    我有啊 package com.imooc.smm.controller; import com.imooc.smm.entity.Department; import com.imooc.smm.service.DepartmentService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.List; @Controller("departmentController") public class DepartmentController { @Autowired private DepartmentService departmentService; public void list(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { List<Department> list = departmentService.selectall(); request.setAttribute("LIST",list); request.getRequestDispatcher("../Department_list.jsp").forward(request,response); } }
    2019-03-08 09:41:14
  • chrismorgen 回复 提问者 月鑫 #2
    你好同学,建议你粘贴一下pom文件中的代码,我需要先核对一下你pom文件中是否缺少相应的springjar包,另外建议同学不要将代码粘贴到回复中,否则会失去代码格式,而要粘贴到回答中,祝学习愉快~
    2019-03-08 14:47:21
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
SSM主流框架入门与综合项目实战2018版
  • 参与学习           人
  • 提交作业       205    份
  • 解答问题       4317    个

Java中非常实用的SSM整合开发内容,从Spring开始,到MyBaits的进阶内容,再到SpringMVC的应用,最后是SSM整合开发案例,逐步深入,助你成长为一名Java工程师!

了解课程
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师