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


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

    }

}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



猜您在找 org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.NullPointerException 成功解决 org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalStateException:报错 org.springframework.web.util.NestedServletException : Handler processing failed; nested exception is java.lang.StackOverflowError Tomcat服务org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.OutOfMemoryError: Java heap space org.springframework.web.util.NestedServletException:Handlerdispatch failed;nested exception is java.lang.NoSuchMethodErroe; org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.web.multipart.MultipartException: Current request is not a multipart request org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.jboss.resteasy.plug maven项目抛出org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.IncompatibleClassChangeError: Implementing class org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoSuchMethodError: 报错异常原因及解决 Request processing failed; nested exception is java.lang.NullPointerException
 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM