gpt4 book ai didi

java - Thymeleaf 表单将带有空字段的对象发送到 weblogic 服务器中的 Controller

转载 作者:行者123 更新时间:2023-12-02 11:56:58 26 4
gpt4 key购买 nike

我正在将 thymeleaf 用于我的 Web 应用程序。保存和更新功能存在问题。当我想从 ui 保存营销 Activity 时,营销 Activity 对象字段将为空以保留 Controller 类。这个问题刚刚出现在weblogic服务器(12.1.3)中。当我在tomcat服务器上尝试时,没有出现任何错误。

我的编辑和创建页面如下。有几个用于竞选的字段,但我在这里写了其中一些字段。顺便说一句,我确信 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.

更新:

我将我的 ui 字段更改为类似 this 的值邮政。但问题仍然存在。

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

最佳答案

您的表单编码类型是“multipart/form-data”。因此,您必须将 spring.http.encoding.enabled=false 添加到 application.properties。

关于java - Thymeleaf 表单将带有空字段的对象发送到 weblogic 服务器中的 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47529754/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com