0

웹 응용 프로그램에 thymeleaf를 사용하고 있습니다. 저장 및 업데이트 기능에 문제가 있습니다. UI에서 캠페인을 저장하려고 할 때 캠페인 객체 필드는 컨트롤러 클래스를 종료하기 위해 null이됩니다. 이 문제는 weblogic 서버에서만 발생합니다 (12.1.3). 내가 Tomcat 서버에서 시도 할 때 어떤 오류도 발생하지 않습니다.Thymeleaf 양식이 null 필드가있는 객체를 weblogic 서버의 컨트롤러에 보냅니다.

내 편집 및 생성 페이지는 다음과 같습니다. 캠페인을위한 몇 가지 필드가 있지만 여기에 그 중 일부를 썼습니다. Bytheway, html 페이지에서 모든 필드를 사용할 준비가되었습니다. 그들 중 일부는 숨겨졌으며 일부는 눈에 띄었다.

<div class="row"> 
    <form name="Form" class="col s8 offset-s2" id="upload-file-form" 
      enctype="multipart/form-data" th:object="${campaign}" 
      th:action="@{/admin/getCampaign}" onsubmit="return validateForm()" 
      method="post"> 

     <div class="row"> 
      <input type="hidden" th:field="*{id}"/> 
      <input type="hidden" th:field="*{version}"/> 
     </div> 
     <div class="row"> 
      <div class="input-field"> 
       <input id="brandname" type="text" class="validate" th:field="*{brandname}"> 
       <label for="brandname">Brand Name</label> 
      </div> 
     </div> 
    </form> 
</div> 

@RequestMapping(value = "admin/getCampaign", method = RequestMethod.POST) 
public String uploadingPost(@RequestParam("uploadingFiles") MultipartFile[] uploadingFiles, 
          @RequestParam("uploadingFiles1") MultipartFile[] uploadingFiles1, 
          @RequestParam("uploadingFiles2") MultipartFile[] uploadingFiles2, 
          @RequestParam("uploadingFiles3") MultipartFile[] uploadingFiles3, 
          Campaign campaign) throws IOException { 

/** this is my controller method for save or update. 
*/                
} 

in weblogic server campaign parameter fields come null (as a new object), but in tomcat server, everything is normal. 

업데이트 :

나는 this 후 같은 가치를 내 UI 필드를 변경했습니다. 그러나 문제는 계속됩니다.

<input type="hidden" th:value="*{id}"/> 
+0

어떤 thymeleaf 버전을 사용하고 있습니까? – Antoniossss

+0

spring-boot-starter-thymeleaf (1.5.7.release)를 사용하고 있습니다. –

답변

1

양식에 enctype이 "multipart/form-data"입니다해야합니다. application.properties에 spring.http.encoding.enabled=false을 추가해야합니다.

+0

신의 축복이 있습니다! :디 –

0

<input type="hidden" th:field="*{id}"/>하지 th:value

+0

이미 필드입니다. 나는 단지 그것을 가치있게 시도합니다. –

+1

그냥 작동해야하지만 잘못하지 않으면 thymeleaf 시동기에 thymeleaf 2가 있고 그 안에 형식이 잘못되었습니다. thymeleaf의 최신 버전으로 전환하는 것이 좋습니다. thymeleaf 3에서와 똑같이 작동합니다. – Antoniossss

+0

나는 thymeeaf 버전을 변경했습니다. 그러나 문제는 해결되지 않았습니다. –

관련 문제