관리 메뉴

IT.FARMER

Spring @annotation 사용시 주의점 및 사용 방법 ?? 수정중,.,.. 본문

Spring

Spring @annotation 사용시 주의점 및 사용 방법 ?? 수정중,.,..

아이티.파머 2011. 11. 17. 11:17
반응형
@RequestParam 사용시 주의점

required = true 의 default 값은 true 이며 , parameter로 값이 넘어 오지 않으면 Error 발생
String 으로 선언 하였으나 Integer 값으로 넘어오면 Error발생
반대로 Integer값으로 선언 하였으나 Parameter가 숫자로 넘어 오지 않으면 Error 발생
null이 들어가도 Error발생
Int 정형변수 보다는 Integer 래퍼(warpper)를 사용하는게 안전하다고 함.

예제.
methodName(@RequestParam(value="ab_kind", required = true , defaultValue = "") String ab_kind ) {
.
.
}
 




@RequestMapping

@RequestMapping(value="/employ/common/{getHumanResourceCodeList}"
@PathVariable

PathVaiable로 어떤 값이 넘어 왔는지 확인 가능함. 즉 PathVaiable을 methdo 변수 로 활용할수 있음
어떻게? 이렇게!!

publuc getUserList(@PathVaible("getHumanResourceCodeList") String requestMappingUrl) {

}
 

 
   @ModelAttribute

bind() 와 같은 맥락으로 보임 단, request.setAttribute 해주지 않아도 자동으로 인식됨
public String method(@ModelAttribute("member")  Member member) {


 @Resource

bean Auto ....
의존관계 자동 주입.
변수
(value, ....) 

 
@Autowride

의존관계 자동 설정시 사용함.

같은 Bean 두개 이상 발생시 Error......발생한다고 하나 아직 본적 없음.
발생되면 원본을 제외한 다른 Bean을 @Required false로 변경해야한다. (기본이 true)




수정중..
반응형