Java “消息参数条件”;“拒绝”;实际请求参数未满足:原因={}
我的Thymeleaf模板和/或控制器有问题 模板如下所示:Java “消息参数条件”;“拒绝”;实际请求参数未满足:原因={},java,spring,spring-boot,httprequest,thymeleaf,Java,Spring,Spring Boot,Httprequest,Thymeleaf,我的Thymeleaf模板和/或控制器有问题 模板如下所示: <div align="left"> <form action="#" th:action="@{/rejection/{invoiceId}(invoiceId=${invoiceId})}" th:object="${rejection}" method="post"> <ul class="form-style-1"> <li>
<div align="left">
<form action="#" th:action="@{/rejection/{invoiceId}(invoiceId=${invoiceId})}" th:object="${rejection}" method="post">
<ul class="form-style-1">
<li>
<label>Powód odrzucenia:<span class="required">*</span></label>
<input type="text" th:field="*{reason}" id="reason" required>
</li>
<li>
<input type="submit" value="Wyślij powód odrzucenia protokołu"/>
</li>
</ul>
</form>
</div>
当我试图从拒绝模板发送数据时,我收到一个错误:
2019-06-12 15:04:13.451 WARN 23678 --- [nio-8080-exec-9] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.bind.UnsatisfiedServletRequestParameterException: Parameter conditions "rejection" not met for actual request parameters: reason={some text here}]
以下是拒绝类:
@Data
@AllArgsConstructor
public class Rejection {
private String invoiceId;
private String reason;
}
我做错了什么?请求参数是一个
拒绝
对象,而不仅仅是拒绝
字段原因
。您看到错误的原因是您在@PostMapping
中有params=“拒绝”
。它需要一个名为拒绝
的参数,而您没有提供任何参数。除非你有特殊的理由,否则就把它去掉
@Data
@AllArgsConstructor
public class Rejection {
private String invoiceId;
private String reason;
}