Summary - 프레임워크에 대한 이해, 데이터 저장계층 또는 영속계층(Persistence Layer)에 대한 이해, 접근 지정자(Access modifier), 서버 프로그램 테스트하기

CODEDRAGON Development/Software Engineering

반응형



 

프레임워크에 대한 이해

https://codedragon.tistory.com/5939

 

 

 

 

 

데이터 저장계층 또는 영속계층(Persistence Layer)에 대한 이해

https://codedragon.tistory.com/6467

https://codedragon.tistory.com/4758

 

 

 

 

 

 

접근 지정자(Access modifier)

https://codedragon.tistory.com/2419

 

 

 

 

 

 

서버 프로그램 테스트하기

Step

설명

테스트 케이스를 작성합니다.

테스트 케이스 작성해야 요소를 작성합니다.

테스트 데이터를 작성합니다.

테스트에 필요한 DB Data 또는 File Data를 규칙에 맞게 생성합니다.

테스트 도구를 설정합니다.

JUnit을 사용하기 위한 Wizard를 선택하고 Next를 클릭합니다.

Test Case의 이름을 입력하고 Finish를 클릭합니다.

테스트 도구를 실행합니다.

테스트 프로그램 오른쪽 버튼 클릭 후 Run As…를 이용하여 수행합니다.

테스트 결과를 명세화합니다.

테스트 결과를 확인합니다.

테스트케이스 계획서에 결과 및 필요사항을 기록합니다.

결함을 보완합니다.

오류 디버깅을 통해 결함을 보완합니다.

https://codedragon.tistory.com/5950

 

 

 

 

 

서버 프로그램 작성 시 요청 URL 생성(접속경로) 예시

server

localhost

port

8080

context root

/system

type

GET

 

@RequestMapping("/test/testMethod.do")

public ModelAndView testMethod(@RequestParam Map<String, Object> params) {

     ModelAndView mv = new ModelAndView();

     // : 315

     int userIdx = Integer.valueOf(params.get("userIdx").toString());

     // : NCS

      String userName = params.get("userName").toString();

     mv.addObject("today", "2017-11-13");

     mv.setViewName("/test/returnPage");

      return mv;

}

https://codedragon.tistory.com/8172

 

 

http://localhost:8080/system/test/testMethod.do?userIdx=315&userName=NCS

 

 

 

 

 

jQuery 통한 문서객체 접근 코드 예시

HTML문서의 [비밀번호 입력][비밀번호 확인] 값을 jQuery 이용해 가져오고,

그 값을 비교하여 다를 경우 경고창을 표시하는 코드 예시입니다.

 

HTML

<label class="block clearfix">

      비밀번호 입력

      <span class="block input-icon input-icon-right">

           <input type="password" id="passwd" name="passwd"/>

      </span>

</label>

<label class="block clearfix">

      비밀번호 확인

      <span class="block input-icon input-icon-right">

           <input type="password" id="rptPasswd"/>

      </span>

</label>

jQuery

var userPw1 = $('#passwd').val();

var userPw2 = $('#rptPasswd').val();

if(userPw1 != userPw2){

      alert("비밀번호가 다름");

      return;

}

https://codedragon.tistory.com/6591

 

 

var userPw1 = $('#passwd').val();

var userPw2 = $('#rptPasswd').val();

if(userPw1 != userPw2){

      alert("비밀번호가 다름");

      return;

}

 

 

 

 

 

비동기 호출을 하는 코드 예시

URL

/weather/getInfo.do

 

Parameter

날짜(date)=20180413,

항목(item)=temp,

구분(type)=avg

Code

$.ajax({

      url:  /wpf/weather/getInfo.do ,

      type: 'POST' ,

      data: {date:20180413, item:temp, type:avg},   

      success: function(result, textStatus, jqXHR) {

      },

      error: function(jqXHR, textStatus, errorThrown) {

      }

});

 

 

(A) /wpf/weather/getInfo.do

(B) {date:20180413, item:temp, type:avg}

 

 

 

 

 

 

서버 프로그램 작성 시 파라미터 전달 오류 분석

434 Line에서 파라미터를 Map에서 꺼내기 위해 get 메서드를 사용하고, 이때 key"userIdx" 입력하였다. 하지만 요청에 해당 key (value) 없기 때문에 Null 반환되었습니다.

Integer.valueOf() 메서드는 String 타입의 값(value) int 형으로 변환(casting) 해주는데 매개변수가 null 이기 때문에 에러가 납니다. , /test/testMethod.do 요청 JSP에서 파라미터를 제대로 입력하지 않아 오류가 발생합니다.

 

호출 방식

GET

호출 URL

http://localhost:8080/grid/test/testMethod.do

Exception

Exception : 

java.lang.NullPointerException

    com.edu.controller.BoardController.testMethod(BoardController.java:434)

    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

    sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

    sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

  ...

CODE

430      @RequestMapping("/test/testMethod.do")

431      public ModelAndView testMethod(@RequestParam Map<String, Object> params) {

432           ModelAndView mv = new ModelAndView();

433           

434           int userIdx = Integer.valueOf(params.get("userIdx").toString());     // 에러

435           

436           String userName = params.get("userName").toString();

437

438           mv.addObject("today", "2017-11-13");

439           mv.setViewName("/test/returnPage");

440           return mv;

441      }

https://codedragon.tistory.com/5938

https://codedragon.tistory.com/5920

https://codedragon.tistory.com/5941

 

반응형