javaspring-mvcmodel-view-controllerthymeleafweblogic12c

Thymeleaf form send object with null fields to controller in weblogic server


I'm using thymeleaf for my web application. There is a problem about save and update functions. When I want to save a campaign from ui, the campaign object fields come null to rest controller class. This problem just occure in weblogic server(12.1.3). When I try it in tomcat server, do not occure any error.

my edit and create page as follow. There are a few fields for campaign, but I wrote some of them in here. Bytheway, I am sure that all fields ready in the html page. Some of them hidden, some of them visible.

<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.

UPDATE:

I changed my ui fields to value like this post. But the problem continue.

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

Solution

  • Your form enctype is "multipart/form-data". So you must add spring.http.encoding.enabled=false to application.properties.