Spring Boot MVC Sample

Serivce

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

Service Implement

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

Controller

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

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

返回頂部