隠し値フィールドを持つフォームがある:Thymeleaf:フィールド
<input type = "hidden" th:field="*{key}" value="keyapp" />
<input type = "hidden" th:field="*{secret}" value="supersecret" />
問題は、これらのフィールドは、コントローラ内の空として渡されていることであるが、隠された番目の所定値を渡すことはできません。 HTML値で事前定義されたthymeleafフィールドを渡す方法はありますか?
おかげで、よろしく、 Deniss更新
:
th:object
定義:
<form th:action="@{..//do-login}" method="POST" modelAttribute="authEntity" th:object="${authEntity}">
AuthEntity.class
public class AuthEntity {
private String key;
private String secret;
private String scope;
private String grantType;
private String username;
private String password;
... // getters & setters omitted // ...
* Controller.class
@RequestMapping(value = "/do-login", method = RequestMethod.POST, produces = "application/json")
public void doLogin (@ModelAttribute("authEntity") final AuthEntity authEntity,
final Model model,
HttpServletResponse servletResponse, HttpSession httpSession) throws IOException {
log.info("Application Key: {}, Secret: {}", authEntity.getKey(), authEntity.getSecret());
フォームをどのように定義しましたか? 'あなたは何を定義しましたか?このオブジェクトは 'key'と' secret'プロパティを持っていますか?これらの値をModelMapに入れたら、 '$ {key}'と '$ {secret} 'で参照する必要があります。 –
@ThomasPawlitzki上記の更新を参照してください。 'th:field'を使うだけで他のすべてのパラメータが正しく渡されることにも注意してください。 –
' key'と 'secret'フィールドを設定していますか? MVC Handlerの値をどのように取得しようとしますか? –