Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring mvc HTTP状态500-请求处理失败;_Spring Mvc_Thymeleaf - Fatal编程技术网

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

Spring mvc HTTP状态500-请求处理失败;,spring-mvc,thymeleaf,Spring Mvc,Thymeleaf,这是我的同意模式 @Entity @Table(name = "consents") public class Consent extends BaseEntity { /** */ @OneToOne @JoinColumn(name = "provider_id") private Provider provider; @OneToOne @JoinColumn(name = "user_id") private

这是我的同意模式

    @Entity
@Table(name = "consents")
public class Consent extends 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;


    @Column(name = "status")
    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;
    }



}
这是同意控制器获取声明

@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();
        //document.addConsent(consent);
        //provider.addDocument(document);
        //user.addProvider(provider);
        model.addAttribute("provider",provider);
        model.addAttribute("document", document);
        model.addAttribute("user", user);
        model.addAttribute("users", users);
        model.addAttribute("consent", consent);
        return "providers/createOrUpdateConsentForm";

}
 @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(consent.getProvider());
        c.setDocument(consent.getDocument());
        c.setUser(user);
        c.setStatus(consent.getStatus());
        c.setFriend(consent.getFriend());
        System.out.print("consentcontroller11");
        System.out.println(consent.getProvider());
        System.out.print("consentcontroller11");
    if (result.hasErrors()) {
        return "providers/createOrUpdateConsentForm";
    } else {
        this.clinicService.saveConsent(c);
        status.setComplete();
    return "redirect:/users/{userId}";
}

}
ELEAF表格的同意书如下:

                          <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 th:field="*{document.provider.id}" name="provider" id="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}"  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 th:field="*{document.id}"  id ="document_id"  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 th:field="*{user.id}" id="friend_id"  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" 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>

服务提供商
选择一个服务提供商
[姓名]
PII文件
和…分享
选择要将文档共享给的用户
[姓名]
同意
添加同意
提交表格后。我得到这个错误

HTTP状态500-请求处理失败;嵌套异常是org.thymeleaf.exceptions.TemplateProcessingException:exception评估SpringEL表达式:“user.providers”(providers/createorUpdateConentForm

org.springframework.expression.spel.SpelEvaluationException:EL1007E:(位置0):在null上找不到字段或属性“providers”

我的用户类:

    @Entity
@Table(name = "users")
public class User extends Person {
    @Column(name = "gender")
    @NotEmpty
    private String gender;


    @Column(name = "birth_date")
    private String birthDate;

    @Column(name = "email")
    @NotEmpty
    private String email;

    @Column(name = "username")
    @NotEmpty
/*    @Digits(fraction = 0, integer = 10)*/
    private String username;

    @Column(name = "password")
    @NotEmpty
/*    @Digits(fraction = 0, integer = 10)*/
    private String password;

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "user")
    private Set<Provider> providers;

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "user")
    private Set<Document> documents;

    @JsonManagedReference
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "user")
    private Role role;

    public void setProviders(Set<Provider> providers) {
        this.providers = providers;
    }
    public void setDocuments(Set<Document> documents) {
        this.documents = documents;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public String getBirthDate() {
        return birthDate;
    }

    public void setBirthDate(String birthDate) {
        this.birthDate = birthDate;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    protected void setProvidersInternal(Set<Provider> providers) {
        this.providers = providers;
    }

    protected void setDocumentsInternal(Set<Document> documents) {
        this.documents = documents;
    }


    protected Set<Provider> getProvidersInternal() {
        if (this.providers == null) {
            this.providers = new HashSet<Provider>();
        }
        return this.providers;
    }


    protected Set<Document> getDocumentsInternal() {

        if (this.documents == null) {
            this.documents = new HashSet<Document>();
        }
        return this.documents;
    }

    public List<Provider> getProviders() {
        List<Provider> sortedProviders = new ArrayList<Provider>(getProvidersInternal());
        PropertyComparator.sort(sortedProviders, new MutableSortDefinition("name", true, true));
        System.out.print("sortedProvider");
        System.out.print(sortedProviders);

        return Collections.unmodifiableList(sortedProviders);
    }

    public List<Document> getDocuments() {
        List<Document> sortedDocuments = new ArrayList<Document>(getDocumentsInternal());
        PropertyComparator.sort(sortedDocuments, new MutableSortDefinition("name", true, true));
        System.out.print("sortedDocuments");
        System.out.print(sortedDocuments);
        return Collections.unmodifiableList(sortedDocuments);
    }


    public void addProvider(Provider provider) {
        getProvidersInternal().add(provider);
        provider.setUser(this);
    }

    public void addDocument(Document document, Provider provider) {
        getDocumentsInternal().add(document);
        System.out.print("addDocument");
        System.out.print(document);
        document.setUser(this);
        document.setProvider(provider);
        System.out.print("addDocument");
        System.out.print(document);

    }
    /**
     * Return the Pet with the given name, or null if none found for this Owner.
     *
     * @param name to test
     * @return true if pet name is already in use
     */
    public Provider getProvider(String name) {
        return getProvider(name, false);
    }

    public Document getDocument(String name) {
        return getDocument(name, false);
    }

    /**
     * Return the Pet with the given name, or null if none found for this Owner.
     *
     * @param name to test
     * @return true if pet name is already in use
     */
    public Provider getProvider(String name, boolean ignoreNew) {
        name = name.toLowerCase();
        for (Provider provider : getProvidersInternal()) {
            if (!ignoreNew || !provider.isNew()) {
                String compName = provider.getName();
                compName = compName.toLowerCase();
                if (compName.equals(name)) {
                    return provider;
                }
            }
        }
        return null;
    }

    public Document getDocument(String name, boolean ignoreNew) {
        name = name.toLowerCase();
        for (Document document : getDocumentsInternal()) {
            if (!ignoreNew || !document.isNew()) {
                String compName = document.getName();
                compName = compName.toLowerCase();
                if (compName.equals(name)) {
                    return document;
                }
            }
        }
        return null;
    }



    public Role getRole() {
        return role;
    }

    public void setRole(Role role) {
        this.role = role;
    }

    @Override
    public String toString() {
        return new ToStringCreator(this)

                .append("id", this.getId())
                .append("new", this.isNew())
                .append("lastName", this.getLastName())
                .append("firstName", this.getFirstName())
                .append("gender", this.gender)
                .append("bithDate", this.birthDate)
                .append("email", this.email)
                .append("username", this.username)
                .append("password", this.password)
                .toString();
    }
}
@实体
@表(name=“users”)
公共类用户扩展Person{
@列(name=“gender”)
@空空如也
私人字符串性别;
@列(name=“出生日期”)
私人字符串生日;
@列(name=“email”)
@空空如也
私人字符串电子邮件;
@列(name=“username”)
@空空如也
/*@位(分数=0,整数=10)*/
私有字符串用户名;
@列(name=“password”)
@空空如也
/*@位(分数=0,整数=10)*/
私有字符串密码;
@OneToMany(cascade=CascadeType.ALL,mappedBy=“user”)
私人设置提供商;
@OneToMany(cascade=CascadeType.ALL,mappedBy=“user”)
私人文件;
@JsonManagedReference
@OneTONE(cascade=CascadeType.ALL,mappedBy=“用户”)
私人角色;
公共无效集合提供程序(集合提供程序){
这个。提供者=提供者;
}
公共作废集合文档(集合文档){
本文件=文件;
}
公共字符串getGender(){
返回性别;
}
公共无效设置性别(字符串性别){
这个。性别=性别;
}
公共字符串getBirthDate(){
返回出生日期;
}
public void setBirthDate(字符串生日){
this.birthDate=生日;
}
公共字符串getEmail(){
回复邮件;
}
公用电子邮件(字符串电子邮件){
this.email=电子邮件;
}
公共字符串getUsername(){
返回用户名;
}
public void setUsername(字符串用户名){
this.username=用户名;
}
公共字符串getPassword(){
返回密码;
}
public void setPassword(字符串密码){
this.password=密码;
}
受保护的无效集合提供程序内部(集合提供程序){
这个。提供者=提供者;
}
受保护的无效集合文档内部(集合文档){
本文件=文件;
}
受保护集getProvidersInternal(){
if(this.providers==null){
this.providers=new HashSet();
}
将此文件返回给提供商;
}
受保护集getDocumentsInternal(){
if(this.documents==null){
this.documents=new HashSet();
}
归还此文件;
}
公共列表getProviders(){
List sortedProviders=new ArrayList(getProvidersInternal());
排序(sortedProviders,新的可变SortDefinition(“name”,true,true));
系统输出打印(“sortedProvider”);
系统输出打印(分拣机);
返回集合。不可修改列表(sortedProviders);
}
公共列表文件(){
List-sortedDocuments=new-ArrayList(getDocumentsInternal());
排序(sortedDocuments,新的可变SortDefinition(“name”,true,true));
系统输出打印(“分类文件”);
系统输出打印(分拣文件);
返回集合。不可修改列表(分类文档);
}
public void addProvider(提供程序提供程序){
getProvidersInternal().add(提供程序);
provider.setUser(这个);
}
公共无效添加文档(文档文档、提供程序){
getDocumentsInternal().add(文档);
系统输出打印(“添加文档”);
系统输出打印(文件);
document.setUser(本文件);
文件。设置提供程序(提供程序);
系统输出打印(“添加文档”);
系统输出打印(文件);
}
/**
*返回具有给定名称的宠物,如果找不到此所有者的宠物,则返回null。
*
*@param要测试的名称
*@如果宠物名已在使用,则返回true
*/
公共提供程序getProvider(字符串名称){
返回getProvider(名称,false);
}
公共文档getDocument(字符串名称){
返回getDocument(名称,false);
}
@RequestMapping(value = "/users/{userId}/providers/{providerId}/documents/{documentId}/consents/new", method = RequestMethod.POST)
public String processNewConsentForm(Model model, @PathVariable("userId") int userId, @PathVariable("providerId") int providerId, 
        @PathVariable("documentId") int documentId, @ModelAttribute("consent") Consent consent, BindingResult result, SessionStatus status) {

    ...
    if (result.hasErrors()) {

        User user = this.clinicService.findUserById(userId);
        Provider provider = this.clinicService.findProviderById(providerId);
        Document document = this.clinicService.findDocumentById(documentId);
        Collection<User> users = this.clinicService.AllUsers();

        model.addAttribute("provider",provider);
        model.addAttribute("document", document);
        model.addAttribute("user", user);
        model.addAttribute("users", users);
        model.addAttribute("consent", consent);

        return "providers/createOrUpdateConsentForm";
    } 
    ...
}