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