ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 스프링 오류 모음
    카테고리 없음 2024. 3. 8. 17:00


    Field error in object 'imageVO' on field 'imageFile': rejected value [냥이발쿠션.png]; codes [typeMismatch.imageVO.imageFile,typeMismatch.imageFile,typeMismatch.org.springframework.web.multipart.MultipartFile,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [imageVO.imageFile,imageFile]; arguments []; default message [imageFile]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'org.springframework.web.multipart.MultipartFile' for property 'imageFile'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'java.lang.String' to required type 'org.springframework.web.multipart.MultipartFile' for property 'imageFile': no matching editors or conversion strategy found]}

     

    대충 해석하면 imageFile을 String 타입에서 MultipartFile 타입으로 변환하는데 실패했다는 오류다. 처음보는 오류라 왜이런가 봤더니, 파일데이터를 업로드한 form태그에 enctype 을 multipart로 설정하지 않아서 그랬다 ㅜ

     


     

    SEVERE: Unhandled exception occurred whilst decorating page
    java.lang.NullPointerException
    at cohttp://m.bbosil.item.util.CategoryGetter.doFilter(CategoryGetter.java:49)

    오류내용.

     

    발생한 코드 내용

    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
    		System.out.println("리스트가 제대로 올까요?" + service.category());
    //		request.setAttribute("category", service.category()); 
    		chain.doFilter(request, response);
    	}

     

    위와 같은 코드에서 category를 불러오는 리스트를 service객체의 category()로 불러오는데, mapper.java 와 mapper.xml, itemService 인터페이스에는 전혀 문제가 없어보였다. 

     

    그런데 내가 필터를 만들기 위해 변경했던 파일들을 찾아보니,  myBatis mapper를 통해DB에 접근하는  기능을 수행하는 category() 메서드를 수기로 작성해서, @Override를 붙이지 않았단 사실을 알게되었다.

    @Service
    @Qualifier("itemServiceImpl")
    public class ItemServiceImpl implements ItemService{
    
    	@Inject
    	private ItemMapper mapper;
    	
    	public List<CategoryVO> category(){
    		return mapper.category();
    	}
    	
    	@Override
    	public List<ItemVO> list(PageObject pageObject) {
    		pageObject.setTotalRow(mapper.getTotalRow(pageObject));
    		return mapper.list(pageObject);
    	}

     

    핵심 : 인터페이스를 통해 추상메서드를 작성한 경우 , 이를 구현할 메서드를 작성할 때 반드시 @Override를 붙여주자 !

     

     


    ERROR: com.bbosil.exception.CommonExceptionAdvice - Exception .....Optional long parameter 'itemNo' is present but cannot be translated into a null value due to being declared as a primitive type. Consider declaring it as object wrapper for the corresponding primitive type.
    ERROR: com.bbosil.exception.CommonExceptionAdvice - {exception=java.lang.IllegalStateException: Optional long parameter 'itemNo' is present but cannot be translated into a null value due to being declared as a primitive type. Consider declaring it as object wrapper for the corresponding primitive type.}

     

    컨트롤러에서 매개변수로 받기로 설정했으나, null 값이 넘어와서 그렇다. 

     

    jsp에서 컨트롤로의 매개변수로 설정한 변수 이름과 똑같은 name이나 key&value로 값을 넘겼는지 확인하자!

Designed by Tistory.