ユーザー管理システムを現在作成していまして、
編集画面を現在作成しているのですが、
formからpasswordを送信することが出来ずにいます。
新規作成画面では
thymeleaf
<form th:action="@{/users}" th:object="${form}" method="POST"> <label for="login_id">ログインID</label> <input type="text" th:field="*{login_id}"/> <label for="name">氏名</label> <input type="text" th:field="*{name}" value="*{name}" /> <label for="rawPassword">パスワード</label> <input type="password" th:field="*{rawPassword}" /> <label for="rawPassword">パスワード(確認用)</label> <input type="password" th:field="*{rawPassword}" /> <label for="branch_id">支店</label> <select th:field="*{branch_id}" id="branch_id"> <option value=1 th:text="本社"></option> <option value=2 th:text="A支社"></option> <option value=3 th:text="B支社"></option> <option value=4 th:text="C支社"></option> </select> <label for="department_id">部署</label> <select th:field="*{department_id}" id="department_id"> <option value=1 th:text="人事総務部"></option> <option value=2 th:text="情報管理部"></option> <option value=3 th:text="営業部"></option> <option value=4 th:text="技術部"></option> </select> <label for="active"></label> <input type="hidden" value=0 th:field="*{active}" /> <input type="submit" value="登録"> </form>
この書き方で, th:objectとth:fieldを使用して送ることが出来たのですが、
編集画面のほうではth:fieldを使用すると画面表示前にエラーが起きてしまいます。
他の項目の値については編集画面に送っていた値を、
th:field=${getoneuser.login_id}という風に記述すると編集画面のフォームにも入り、
送信もできることも確認したのですがpasswordを編集画面から送る方法はありますでしょうか?
ご回答お願い致します。
Thymeleaf
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"> <head> <meta charset="UTF-8"> <title>ユーザー編集</title> </head> <body> <form th:action="@{/users/edituser}" th:object="${editUserForm}" method="POST"> <label for="login_id">ログインID変更</label> <input type="text" th:field="${getoneuser.login_id}"/> <label for="name">氏名変更</label> <input type="text" th:field="${getoneuser.name}"/> <label for="password">新規パスワード</label> <input type="text" th:field=""/> <label for="password">新規パスワード(確認用)</label> <input type="text"/> <label for="branch_id">支店変更</label> <select th:field="${getoneuser.branch_id}" id="branch_id"> <option value=1 th:text="本社"></option> <option value=2 th:text="A支社"></option> <option value=3 th:text="B支社"></option> <option value=4 th:text="C支社"></option> </select> <label for="department_id">部署変更</label> <select th:field="${getoneuser.department_id}" id="department_id"> <option value=1 th:text="人事総務部"></option> <option value=2 th:text="情報管理部"></option> <option value=3 th:text="営業部"></option> <option value=4 th:text="技術部"></option> </select> <p th:text="${getoneuser.login_id}"></p> <p th:text="${getoneuser.name}"></p> <p th:text="${getoneuser.password}"></p> <p th:text="${getoneuser.branch_id}"></p> <p th:text="${getoneuser.department_id}"></p> <input type="hidden" value=${id}/> <input type="submit" value="更新"> </form> <a th:href="@{/users}">戻る</a> </body> </html>
まだ回答がついていません
会員登録して回答してみよう