Home > Back-end >  Distributed null pointer exception occurred after gateway query the database projects but you can fi
Distributed null pointer exception occurred after gateway query the database projects but you can fi

Time:09-23

@ RequestMapping ("/")
Public String showPortalPage Model (Model) {

//1. The way to call MySQLRemoteService provides query page to display the data
ResultEntity ResultEntity=mySQLRemoteService. GetPortalTypeProjectDataRemote ();//hint here data
//is empty

//2. Check the query results
The String result=resultEntity. GetResult ();
If (ResultEntity. SUCCESS. Equals (result)) {

//3. Obtain the query data
List List=resultEntity. GetData ();

//4. Deposit model
Model. The addAttribute (CrowdConstant ATTR_NAME_PORTAL_DATA, a list).
}

Return "portal";
}

Expose interfaces//
@ FeignClient (" atguigu - the crowd - mysql ")
Public interface MySQLRemoteService {

@ RequestMapping ("/get/portal/type/project/data/remote ")
Public ResultEntity GetPortalTypeProjectDataRemote ();
}

//database part
@ RequestMapping ("/get/portal/type/project/data/remote ")
Public ResultEntity GetPortalTypeProjectDataRemote () {
Try {
List PortalTypeVOList=projectService. GetPortalTypeVO ();
Return ResultEntity. SuccessWithData (portalTypeVOList);
} the catch (Exception e) {
e.printStackTrace();
Return ResultEntity. Failed (um participant etMessage ());
}
}