fix nullpointer in settings
This commit is contained in:
parent
fa610cae3b
commit
985169117d
|
@ -1,6 +1,7 @@
|
|||
package org.hso.ecommerce.controller;
|
||||
|
||||
import org.hso.ecommerce.action.user.UpdateUserSettingsAction;
|
||||
import org.hso.ecommerce.entities.shop.Address;
|
||||
import org.hso.ecommerce.entities.shop.CustomerOrder;
|
||||
import org.hso.ecommerce.entities.user.User;
|
||||
import org.hso.ecommerce.repos.shop.CustomerOrderRepository;
|
||||
|
@ -38,6 +39,9 @@ public class UserController {
|
|||
) {
|
||||
long userId = (long) session.getAttribute("userId");
|
||||
User user = userRepository.findById(userId).get();
|
||||
if(user.defaultDeliveryAddress == null){
|
||||
user.defaultDeliveryAddress = new Address();
|
||||
}
|
||||
model.addAttribute("user", user);
|
||||
|
||||
return "user/settings";
|
||||
|
|
Reference in New Issue