Spring mvc HTTP状态500-预期的会话属性';同意';
这是我同意的html格式。发布输入后,我在浏览器上发现错误Spring mvc HTTP状态500-预期的会话属性';同意';,spring-mvc,Spring Mvc,这是我同意的html格式。发布输入后,我在浏览器上发现错误 <form th:object="${consent}" action="../users/userDetails.html" th:action="@{${#httpServletRequest.servletPath}}" method="post"> <fieldset> <div class="col-sm-7 col-md-6 col-lg-5"> <label f
<form th:object="${consent}" action="../users/userDetails.html" th:action="@{${#httpServletRequest.servletPath}}" method="post">
<fieldset>
<div class="col-sm-7 col-md-6 col-lg-5">
<label for="last_name">Service Provider</label>
<select id="provider" name="provider" class="form-control" th:onchange="'javascript:showPIIDoc(this.value);'">
<option th:value="0" >Select a Service Provider</option>
<option th:each="provider : ${user.providers}" name="name" th:value="${user.id} +','+ ${provider.id}" th:text="${provider.name}" >[name]</option>
</select>
</div>
<div style="clear:both"></div>
<div class="col-sm-7 col-md-6 col-lg-5">
<label for="last_name">PII Document</label>
<select id ="documentdiv" class="form-control">
</select>
</div>
<div style="clear:both"></div>
<div class="col-sm-7 col-md-6 col-lg-5">
<label for="last_name">Share with</label>
<select class="form-control">
<option th:value="0" >Select a user you want share the document to</option>
<option name="name" th:each="user : ${users}" th:value="${user.id}" th:text="${user.firstName} + ' ' + ${user.lastName}">[name]</option>
</select>
</div>
<div style="clear:both"></div>
<div class="col-sm-7 col-md-6 col-lg-5">
<label for="last_name">Consent</label>
<div style="clear:both"></div>
<input type="checkbox" name="share" th:value="1" th:text="Share" />
</div>
<div style="clear:both"></div>
<div style="margin-top:10px;margin-left:10px" class="form-actions">
<button class="btn btn-primary" type="submit">Add Consent</button>
</div>
</fieldset>
</form>
我在浏览器上看到这个错误
<form th:object="${consent}" action="../users/userDetails.html" th:action="@{${#httpServletRequest.servletPath}}" method="post">
<fieldset>
<div class="col-sm-7 col-md-6 col-lg-5">
<label for="last_name">Service Provider</label>
<select id="provider" name="provider" class="form-control" th:onchange="'javascript:showPIIDoc(this.value);'">
<option th:value="0" >Select a Service Provider</option>
<option th:each="provider : ${user.providers}" name="name" th:value="${user.id} +','+ ${provider.id}" th:text="${provider.name}" >[name]</option>
</select>
</div>
<div style="clear:both"></div>
<div class="col-sm-7 col-md-6 col-lg-5">
<label for="last_name">PII Document</label>
<select id ="documentdiv" class="form-control">
</select>
</div>
<div style="clear:both"></div>
<div class="col-sm-7 col-md-6 col-lg-5">
<label for="last_name">Share with</label>
<select class="form-control">
<option th:value="0" >Select a user you want share the document to</option>
<option name="name" th:each="user : ${users}" th:value="${user.id}" th:text="${user.firstName} + ' ' + ${user.lastName}">[name]</option>
</select>
</div>
<div style="clear:both"></div>
<div class="col-sm-7 col-md-6 col-lg-5">
<label for="last_name">Consent</label>
<div style="clear:both"></div>
<input type="checkbox" name="share" th:value="1" th:text="Share" />
</div>
<div style="clear:both"></div>
<div style="margin-top:10px;margin-left:10px" class="form-actions">
<button class="btn btn-primary" type="submit">Add Consent</button>
</div>
</fieldset>
</form>
HTTP状态500-预期的会话属性“同意”
提交表格后
这是GET方法的控制器代码。它过去叫同意书
@RequestMapping(value = "/users/{userId}/providers/{providerId}/documents/{documentId}/consents/new", method = RequestMethod.GET)
public String initNewConsentForm(@PathVariable("userId") int userId,@PathVariable("providerId") int providerId,@PathVariable("documentId") int documentId, Model model) {
User user = this.clinicService.findUserById(userId);
Provider provider = this.clinicService.findProviderById(providerId);
Document document = this.clinicService.findDocumentById(documentId);
Collection<User> users = this.clinicService.AllUsers();
Consent consent = new Consent();
model.addAttribute("provider",provider);
model.addAttribute("document", document);
model.addAttribute("user", user);
model.addAttribute("users", users);
return "providers/createOrUpdateConsentForm";
}
@RequestMapping(value=“/users/{userId}/providers/{providerId}/documents/{documentId}/approves/new”,method=RequestMethod.GET)
公共字符串initnewapproverform(@PathVariable(“userId”)int-userId,@PathVariable(“providerId”)int-providerId,@PathVariable(“documentId”)int-documentId,Model-Model){
User User=this.clinicService.finduserbyd(userId);
提供者提供者=this.clinicService.findProviderById(providerId);
Document Document=this.clinicService.findDocumentById(documentId);
集合用户=this.clinicService.AllUsers();
同意=新的同意();
model.addAttribute(“提供者”,提供者);
model.addAttribute(“文档”,文档);
model.addAttribute(“用户”,用户);
model.addAttribute(“用户”,用户);
返回“providers/createOrUpdateConsentForm”;
}
添加model.addAttribute(“同意”,同意)代码>在GET方法中。为什么在表单中有属性action
和th:action
?我正在使用thymeleaf。我们可以使用这两个属性。我做错了吗?我知道这是thymeleaf,请尝试删除操作
属性。它不适用于相同的问题。你认为这个错误在哪里?在控制器中还是html中@NikolayRusev问题可能出在您提供此表单的方法中。您可以发布GET方法的代码吗。可能是您缺少model.addAttribute(“同意”,新同意())代码>