Spring Boot MVC Sample

Serivce

@Service
public interface LoginService{
    boolean authUser(String userEmail, String authCode);
}

Service Implement

@Service
public class LoginServiceImpl implements LoginService{

    public boolean authUser(String userEmail, String authCode){

        //something checking

        if(true){
            return true;
        }

        return false;
    }
}

Controller

@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";
    }

  }
}

開始在上面輸入您的搜索詞,然後按回車進行搜索。按ESC取消。

返回頂部