这是我的同意形式。发布输入后,我在浏览器上出现错误
<p:dataList var="pdi" value="#{FormGenerator.formItemsForDisplay}" id="all" varStatus="loop" type="none">
<p:panel id="panel" header="#{pdi.key.getFragmentDefinition().getFragmentName()}" style="margin-bottom:1em; width:100%;">
<pe:fluidGrid id="fluidGrid" value="#{pdi.value}" var="data"
hGutter="20" vGutter="10" widgetVar="fgwv_#{loop.index}">
<pe:fluidGridItem type="stringValue" id="txt_">
<div class="dynaFormLabel">
<p:outputLabel for="txt" value="#{data.label}"/>
</div>
<p:inputText id="txt" value="#{data.value}"/>
</pe:fluidGridItem>
<pe:fluidGridItem type="integerValue" id="int_">
<div class="dynaFormLabel">
<p:outputLabel for="int" value="#{data.label}"/>
</div>
<p:spinner id="int" value="#{data.value}" />
</pe:fluidGridItem>
<pe:fluidGridItem type="dateValue" id="cal_">
<div class="dynaFormLabel">
<p:outputLabel for="cal" value="#{data.label}"/>
</div>
<p:calendar id="cal" value="#{data.value}" showOn="button"/>
</pe:fluidGridItem>
</pe:fluidGrid>
</p:panel>
</p:dataList>
这是我的控制器
<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 Method的Controller代码。它过去常常打电话给同意书
@RequestMapping(value = "/users/{userId}/providers/{providerId}/documents/{documentId}/consents/new", method = RequestMethod.POST)
public String processNewConsentForm(@PathVariable("userId") int userId, @PathVariable("providerId") int providerId,
@PathVariable("documentId") int documentId, @ModelAttribute("consent") Consent consent, BindingResult result, SessionStatus status) {
User user = this.clinicService.findUserById(userId);
Provider provider = this.clinicService.findProviderById(providerId);
System.out.println("daghade");
System.out.println(provider);
Document doc = this.clinicService.findDocumentById(userId);
Consent c =new Consent();
c.setProvider(provider);
c.setDocument(doc);
c.setUser(user);
c.setStatus(c.getStatus());
c.setFriend(c.getFriend());
System.out.println(c);
if (result.hasErrors()) {
return "providers/createOrUpdateConsentForm";
} else {
this.clinicService.saveConsent(c);
status.setComplete();
return "redirect:/users/{userId}";
}
}
答案 0 :(得分:0)
在您的GET方法中添加model.addAttribute("consent", consent);
。