[Practice] 클라이언트 요청에 대한 주소 만들기 (1)
2021. 4. 12. 13:23ㆍSpring/Practice
1. 문제
- 컨트롤러 인식을 위한 Controller 어노테이션 이용
- 주소매핑은 RequestMapping을 이용
- HTTP 메서드는 GET 방식
- 리턴값은 아무것도 없음
- 주소는 "/first-url"
2. 풀이
package com.example.jpa.sample;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
public class FirstController {
@RequestMapping(value = "/first-url", method = RequestMethod.GET)
public void first() {
}
}
※ 반환되는 값이 없기 때문에 에러 발생
Spring Security 설정
package com.example.jpa.sample;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.anyRequest().permitAll();
}
}
728x90
'Spring > Practice' 카테고리의 다른 글
[Practice] 클라이언트 요청에 대한 주소 만들기 (4) (0) | 2021.04.12 |
---|---|
[Practice] 클라이언트 요청에 대한 주소 만들기 (3) (0) | 2021.04.12 |
[Practice] 클라이언트 요청에 대한 주소 만들기 (2) (0) | 2021.04.12 |
[Practice] 프로젝트 생성 (0) | 2021.04.12 |