HTTP状态500 - 请求处理失败;

时间:2015-06-11 08:53:01

标签: 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 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 id="provider_id"  th:each="provider : ${user.providers}"  th:field="*{provider_id}" 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 id="friend_id" name="name" th:each="user : ${users}"  th:field="*{friend_id}"  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" id="status" th:field="*{status}" 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>

这是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);
        model.addAttribute("consent", consent);
        return "providers/createOrUpdateConsentForm";

}

这是POST控制器

@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) {

    System.out.print("consentcontroller11");

    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}";
}

} 

模型

@Entity

@Table(name =&#34;同意&#34;) 公共类同意扩展BaseEntity {

/**

 */
@OneToOne
@JoinColumn(name = "provider_id")
private Provider provider;

@OneToOne
@JoinColumn(name = "user_id")
private User user;

@OneToOne
@JoinColumn(name = "friend_id")
private User friend;


@OneToOne
@JoinColumn(name = "document_id")
private Document document;

private String status;

/**
 * C
 * @return 
 */
public void Provider() {
}

public Provider getProvider() {
    return this.provider;
}

/**
 * Setter for property pet.
 *
 * @param pet New value of property pet.
 */
public void setProvider(Provider provider) {
    this.provider = provider;
}


public User getUser() {
    return user;
}


public void setUser(User user) {
    this.user = user;
}


public User getFriend() {
    return friend;
}


public void setFriend(User friend) {
    this.friend = friend;
}


public Document getDocument() {
    return document;
}


public void setDocument(Document document) {
    this.document = document;
}


public String getStatus() {
    return status;
}


public void setStatus(String status) {
    this.status = status;
}

}

我收到此错误

  

HTTP状态500 - 请求处理失败;嵌套异常是org.thymeleaf.exceptions.TemplateProcessingException:执行处理器期间出错&org.thymeleaf.spring3.processor.attr.SpringOptionFieldAttrProcessor&#39; (提供者/ createOrUpdateConsentForm:248)

请帮帮我!谢谢。

1 个答案:

答案 0 :(得分:0)

尝试这样

Select top 1 Date_Entered, 
Getdate() as FILE_DATE_PROCESSED  
from yourtable 
order by Date_Entered desc

http://www.thymeleaf.org/doc/tutorials/2.1/thymeleafspring.html

th:字段应该在select中,并且应该作为迭代的变量捕获。