码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2018-02-27 12:43:38      阅读:216      评论:0      收藏:0      [点我收藏+]

标签:map   admin   ring   failed   cep   方法   roc   process   poi   

问题:调用的方法在一个接口类中,但我并没有注入那个被调用的类
解决:在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

标签:map   admin   ring   failed   cep   方法   roc   process   poi   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!