1 2 3 4 | @Service public interface LoginService{ boolean authUser(String userEmail, String authCode); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | @Service public class LoginServiceImpl implements LoginService{ public boolean authUser(String userEmail, String authCode){ //something checking if ( true ){ return true ; } return false ; } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | @Controller class LoginController { @Autowired private LoginService loginService; @RequestMapping (value = "/login" , method = RequestMapping.GET) public String index() { return "login" ; } @RequestMapping (value = "/login" , method = RequestMapping.POST) public String login(ModelMap model, @RequestParm ){ if (loginService.authUser(userEmail, authCode)){ return "home_page" ; } else { model.put( "hasError" , true ); return "redirect:/login" ; } } } |