-1

我是 Spring MVC 的新手。我的代码曾经可以工作,但我改变了一些东西,现在它失败了。不幸的是,我不明白那里出了什么问题。这是我得到的错误。任何想法?

public class Site {

    private String siteName;
    private String emailFromAddress;
    private String customerServicesEmailAddress;    
    private String googleAnalyticsAccountId;    
    private String doNotReplyEmailAddress;
    private String customerServicesTelephoneNumber;
    private String takeoverCss;
    private String helpUrl;
    private boolean isSubsite;
    private int searchResultsPerPage;
    private List<BlackWord> blackList;
    private List<QueryOverride> listOverrides; 
    ...
  }
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors
    Field error in object 'site' on field 'listOverrides': rejected value [9]; codes [typeMismatch.site.listOverrides,typeMismatch.listOverrides,typeMismatch.java.util.List,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [site.listOverrides,listOverrides]; arguments []; default message [listOverrides]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.util.List' for property 'listOverrides'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [com.company.tabernus.commerce.domain.QueryOverride] for property 'listOverrides[0]': no matching editors or conversion strategy found]
        org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:894)
        org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:311)
        org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:116)
        org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
        org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
        org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
        org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
        org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:101)
        org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
        org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
        org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
        org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:146)
        org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
        org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
        org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
        org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
        org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
        org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:182)
        org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
        org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
        org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
        org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
        org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
        org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:173)
        org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
        org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
4

1 回答 1

1

我想最有用的一行是:

无法将类型 [java.lang.String] 的值转换为属性“listOverrides [0]”所需的类型 [com.thehutgroup.tabernus.commerce.domain.QueryOverride]:找不到匹配的编辑器或转换策略

Spring 尝试将 type 的值String放入listOverrides但不知道如何将 a 转换String为 a QueryOverride。如果您现在没有做任何完全错误的事情,您可以通过修复来解决问题,那么 Spring 需要知道如何在字符串和 QueryOverrides 之间进行转换(很可能:双向)。您可能想为此研究类型转换器

于 2013-10-08T14:46:03.913 回答