๐น ์๋ฌ
get
๋ฐฉ์์ fetch
๊ฐ ์๋๋ค
header
์ ์ฉํด๋ ์๋๋ค
๐น ์์ธ & ํด๊ฒฐ
โ
ํด๋น ๊ฒฝ๋ก๋ฅผ ์ ํํ๊ฒ ์ํ๋ฆฌํฐ์ permitAll์ด๋ ignoring์ ๋ฃ์ด์ค์ผ ํ๋ค.
security
http.authorizeRequests()
.antMatchers("/whygram","/user/join", "/user/auth", "/user/emailCheck/*").permitAll()
.anyRequest().authenticated();
controller
@ResponseBody
@GetMapping("/emailCheck/{users_email}")
public Map<String, Integer> emailCheck(UserEntity param, @PathVariable String users_email) {
System.out.println(users_email);
param.setUsers_email(users_email);
Map<String, Integer> data = new HashMap();
int result = service.selEmail(param);
data.put("result", result);
return data;
}
๐น ์๋ฌ๋ฉ์์ง
templetInputException
๐น ์์ธ & ํด๊ฒฐ
โ
@responsebody
๋ฅผ ๋ฃ์ด์ค์ผ ํ๋ค.
js
function emailCheck() {
joinEmailElem.value = completeEmail();
const users_email = joinEmailElem.value;
console.log(users_email);
if (!isvalid(emailIdElem, emailExp) || !isNotEmpty(emailAdrsElem)) { return; }
fetch('/user/emailCheck/' + users_email)
.then(res => res.json())
.then(myJson => {
console.log(myJson);
if(myJson.result == 0) {
ok(emailIdElem, "์ฌ์ฉ๊ฐ๋ฅํ ์ด๋ฉ์ผ์
๋๋ค. ์ด๋ฉ์ผ ์ธ์ฆ์ด ํ์ํ ์ ์ ์ํด ์ฃผ์ธ์.");
} else {
warn(emailIdElem, "์ค๋ณต๋ ์ด๋ฉ์ผ์
๋๋ค.");
}
});
}
controller
@ResponseBody
@GetMapping("/emailCheck/{users_email}")
public Map<String, Integer> emailCheck(UserEntity param, @PathVariable String users_email) {
System.out.println(users_email);
param.setUsers_email(users_email);
Map<String, Integer> data = new HashMap();
int result = service.selEmail(param);
data.put("result", result);
return data;
}