首页 > 编程语言 > 详细

error:org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.NullPointerException

时间:2018-02-27 12:29:41      阅读:773      评论:0      收藏:0      [点我收藏+]
问题:调用的方法在一个接口类中,但我并没有注入那个被调用的类
解决:在UserEntity前加上@Autowired
@Controller

public class MainController {



// 自动装配数据库接口,不需要再写原始的Connection来操作数据库

    @Autowired

    UserRepository userRepository;



    @RequestMapping(value = "/",method = RequestMethod.GET)

    public String index(){

        return "index";

    }



    @RequestMapping(value = "/admin/users",method = RequestMethod.GET)

    public String getUsers(ModelMap modelMap){

        List<UserEntity> userList = userRepository.findAll();

        modelMap.addAttribute("userList", userList);

        return "admin/users";

    }

}

 

error:org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.NullPointerException

原文:https://www.cnblogs.com/xym4869/p/8478113.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!