스프링 프레임워크에서 HttpServletRequest, HttpSession 객체 직접 가져오기
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpServletRequest;
ServletRequestAttributes sra = (ServletRequestAttributes)RequestContextHolder.currentRequestAttributes();
// HttpServletReqeust 객체
HttpServletReqeust httpServletReqeust = sra.getRequest();
// HttpSession 객체
HttpSession httpSession = sra.getRequest().getSession();
스프링 프로퍼티 사용하기
*** 설명 ***
Value 어노테이션을 사용하여 프로퍼티 값을 가져올 수 있다.
값에 따라서 String, boolean 등의 형식을 지정할 수 있다.
***예제 ***
@Value("${prop.name1}")
private String propName1;
@Value("${prop.name2}")
private boolean propName2;
Value 어노테이션을 사용하여 프로퍼티 값을 가져올 수 있다.
값에 따라서 String, boolean 등의 형식을 지정할 수 있다.
***예제 ***
@Value("${prop.name1}")
private String propName1;
@Value("${prop.name2}")
private boolean propName2;
피드 구독하기:
글 (Atom)